SDK

Implementation

With the Notificare's Monetize add-on you can easily sell virtual goods in Google Play and 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.

Android

Please note that to be able to test your products, you will need to upload at least an Alpha build of your app to Google Play. Please read this guide to learn how to test products in a sandbox environment.

iOS

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 notificare_monetize dependency.

Before we start interacting with stores, you should have your app listen to several important events emitted by the NotificareMonetize module.

Additionally, on Android, you should wait until the underlying Google Play Billing client becomes available by listening to the following events:

NotificareMonetize.onBillingSetupFinished.listen((event) {
  // It's safe to start a purchase.
});

NotificareMonetize.onBillingSetupFailed.listen((event) {
  // The underlying Google Play Billing client ran into a problem.
});

Listing products and purchases

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

NotificareMonetize.onProductsUpdated.listen((products) {

});

NotificareMonetize.onPurchasesUpdated.listen((purchases) {

});

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

// Products
final products = await NotificareMonetize.products;

// Purchases
final purchases = await NotificareMonetize.purchases;

Starting a purchase

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

await NotificareMonetize.startPurchaseFlow(product);

Your app will be notified about changes in purchases through the NotificareMonetize event streams.

NotificareMonetize.onPurchaseFinished.listen((purchase) {

});

NotificareMonetize.onPurchaseRestored.listen((purchase) {

});

NotificareMonetize.onPurchaseCanceled.listen((purchase) {

});

NotificareMonetize.onPurchaseFailed.listen((event) {

});