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 cordova-plugin-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(() => {
  // It's safe to start a purchase.
});

NotificareMonetize.onBillingSetupFailed(({ code, message }) => {
  // The underlying Google Play Billing client ran into a problem.
});

Listing products and purchases

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

NotificareMonetize.onProductsUpdated((products) => {

});

NotificareMonetize.onPurchasesUpdated((purchases) => {

});

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

// Products
const products = await NotificareMonetize.getProducts();

// Purchases
const purchases = await NotificareMonetize.getPurchases();

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 subscriptions.

NotificareMonetize.onPurchaseFinished((purchase) => {

});

NotificareMonetize.onPurchaseRestored((purchase) => {

});

NotificareMonetize.onPurchaseCanceled((purchase) => {

});

NotificareMonetize.onPurchaseFailed((event) => {

});