SDK

Implementation

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

To be able to use In-App Billing in your application, make you sure you add the following permission to your AndroidManifest.xml:

<uses-permission android:name="com.android.vending.BILLING" />

You will enable this feature in your app by invoking the following method from your Intent Receiver:

Notificare.on('ready', function(data) {

    ...more code

    Notificare.enableBilling();

});
Notificare.on('ready', async (data) => {

  ...more code

  await Notificare.enableBilling();

});

After this point, our library will automatically load any products you've previously created.

In your index.js add the following event listener that will be trigger as soon as your products are ready to be consumed:

Notificare.on('storeLoaded', function(data) {
    //Load your UI
});
Notificare.on('storeLoaded', (data) => {
    //Load your UI
});

If there is some issue with your products or your account, the following event is triggered instead:

Notificare.on('storeFailedToLoad', function(data) {
  //Handle error
});
Notificare.on('storeFailedToLoad', (data) => {
    //Handle error
});

If your store is loaded successfully, at any time you can request the list of products with the following method:

Notificare.fetchProducts(function(products) {
  //Handle success
}, function(e) {
  //Handle error
});
const products = await Notificare.fetchProducts();

You can also retrieve a list of the purchased products, this can be used to allow or not products to be bought again (depending on their type) or automatically give access to the content they unlock. To do that, simply invoke the following method:

Notificare.fetchPurchasedProducts(function(products) {
  //Handle success
}, function(e) => {
  //Handle error
});
const products = await Notificare.fetchPurchasedProducts();

To get a specific product, using any of the objects return from your list of products, invoke the following method:

var product = products[0];
Notificare.fetchProduct(product, function(data) {
  //Handle success
}, function(e) {
  //Handle error
});
const product = Notificare.fetchProduct(products[0]);

Finally to allow a user to buy a product, simply invoke the method below. Invoking this method, will start teh buying process flow which will return some of the events described below in this page.

var product = products[0];
Notificare.buyProduct(product);
await Notificare.buyProduct(product);

In-App Billing Delegates

The method above will start the purchase flow handled by Android and Google Play. You can then use the following delegates to understand the state of the purchase. You should use them to update UI or show errors.

Notificare.on('productTransactionCompleted', function(data) {

});

Notificare.on('productTransactionRestored', function(data) {

});

Notificare.on('productTransactionFailed', function(data) {

});
Notificare.on('productTransactionCompleted', (data) => {

});

Notificare.on('productTransactionRestored', (data) => {

});

Notificare.on('productTransactionFailed', (data) => {

});

This is all you need to display and sell your in-app products.