SDK

Implementation

With the Notificare's Monetize add-on you can easily sell virtual goods in the App Store. Our library will provide you all the mechanisms to quickly develop an engaging in-app store experience where you can sell digital products.

Please note that be able to complete a transaction while using sandbox servers, you will need to create test users with access to your app in Apple’s Developer Portal. Your can find more information about test users here.

To be able to use in-app billing in your application, make sure you add the NotificareMonetizeKit dependency.

Before we start interacting with the App Store, you should have your AppDelegate implement the NotificareMonetizeDelegate to be notified about important events.

class AppDelegate: UIResponder, UIApplicationDelegate, NotificareMonetizeDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

        Notificare.shared.monetize().delegate = self

        // more code...
    }
}

Listing products and purchases

Both products and purchases changes are notified through the NotificareMonetizeDelegate, so it is really easy to hook up your app to a list of products, for example:

class AppDelegate: UIResponder, UIApplicationDelegate, NotificareMonetizeDelegate {

    func notificare(_ notificareMonetize: NotificareMonetize, didUpdateProducts products: [NotificareProduct]) {

    }

    func notificare(_ notificareMonetize: NotificareMonetize, didUpdatePurchases purchases: [NotificarePurchase]) {

    }
}

If you want to get the data at any point in time, you can still get the products and purchases directly.

// Products
Notificare.shared.monetize().products

// Purchases
Notificare.shared.monetize().purchases

Starting a purchase

To start a purchase, you must run the startPurchaseFlow method which will handle the entire process with the App Store.

Notificare.shared.monetize().startPurchaseFlow(product)

Your app will be notified about changes in purchases through the NotificareMonetizeDelegate.

class AppDelegate: UIResponder, UIApplicationDelegate, NotificareMonetizeDelegate {

    func notificare(_ notificareMonetize: NotificareMonetize, didFinishPurchase purchase: NotificarePurchase) {

    }

    func notificare(_ notificareMonetize: NotificareMonetize, didRestorePurchase purchase: NotificarePurchase) {

    }

    func notificareDidCancelPurchase(_ notificareMonetize: NotificareMonetize) {

    }

    func notificare(_ notificareMonetize: NotificareMonetize, didFailToPurchase error: Error) {

    }
}