Qonversion Inc.

The Qonversion Inc. Developer Hub

Welcome to the Qonversion Inc. developer hub. You'll find comprehensive guides and documentation to help you start working with Qonversion Inc. as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Android SDK

Install Qonversion Android SDK to implement in-app subscriptions, validate user receipts, get subscription analytics, and 3-rd party integrations.

Install the library

The recommended way to install the Qonversion library for Android is with a build system like Gradle. The library is distributed via Maven Central.

Add Qonversion library to the dependencies section in your app build.gradle

dependencies {    
     implementation 'com.qonversion.android.sdk:sdk:1.0.6'    
}

Setup

Add the following code to import the Qonversion SDK:

import com.qonversion.android.sdk.Qonversion;

Qonversion SDK can work in two modes depending on your settings:

  1. Manual tracking mode
    In this mode, you need to call SDK methods manually to assign purchases to Qonversion.

  2. Auto-tracking mode
    In this mode, you do not have to worry about assigning purchases to Qonversion. Everything is handled inside the SDK.

See the steps below for manual or auto-tracking modes.

Manual Mode

The SDK initialization has to be called in your Application in the onCreate method.

public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Qonversion.initialize(this, "qonversion_project_key", "yourSideUserID");
    }
}
public class App : Application {
    override fun onCreate() {
        super.onCreate();
        Qonversion.initialize(this, "projectKey", "yourSideUserID");
    }
}

Get your Qonversion Project Key
Read more about user identifiers here
"yourSideUserID" is a user id in your backend. If you don't have one, just create UUID using UUID.randomUUID().toString() and save locally. Read more about user identifiers here.

Set up Google Play Billing Library

You need to set up and initialize Google Play Billing Library, see official Android Developer documentation here.

❗️

Please, do not use Google Play Billing AIDL library to integrate Qonversion SDK with your application. It was deprecated and is not supported by Qonversion SDK.

To track purchase data with the SDK, you need to call the purchase method. This method takes two parameters. These parameters are objects from Google Play Billing Library:

  • Details with type SkuDetails docs.
  • Purchase with type Purchase docs.

The best time to call purchase method is after the onPurchasesUpdated method of BillingClient is called.

📘

For more information, check the example app in the repo ManualTrackingActivity and ManualTrackingActivityKt classes.

@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
     client = BillingClient
              .newBuilder(this)
              .enablePendingPurchases()
              .setListener(new PurchasesUpdatedListener() {
                    @Override
                    public void onPurchasesUpdated(BillingResult billingResult, @Nullable List<Purchase> list) {
                         if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
                              if (list != null && !list.isEmpty()) {
                                   trackPurchase(skuDetails.get(SKU_ID), list.get(0));
                              }
                         }
                    }                
               })
               .build();
         
}

private void trackPurchase(@NonNull SkuDetails details, @NonNull Purchase purchase) {
    Qonversion.getInstance().purchase(details, purchase);
}
override fun onCreate(
        savedInstanceState: Bundle?,
        persistentState: PersistableBundle?
    ) {
        super.onCreate(savedInstanceState, persistentState)
        client = BillingClient
            .newBuilder(this)
            .enablePendingPurchases()
            .setListener { billingResult, list ->
                if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
                    if (list != null && list.isNotEmpty()) {
                        trackPurchase(
                            skuDetails[SKU_ID]!!,
                            list[0]
                        )
                    }
                }
            }
            .build()
        launchBilling()
    }
    
    private fun trackPurchase(
        details: SkuDetails,
        purchase: Purchase
    ) {
        Qonversion.instance!!.purchase(details, purchase)
    }

Auto Tracking mode

Initialize QonversionBillingBuilder

Create an instance of QonversionBillingBuilder (precisely like in Android BillingClient):

private QonversionBillingBuilder buildBilling() {
        return new QonversionBillingBuilder()
                .enablePendingPurchases()
                .setChildDirected(BillingClient.ChildDirected.CHILD_DIRECTED)
                .setUnderAgeOfConsent(BillingClient.UnderAgeOfConsent.UNDER_AGE_OF_CONSENT)
                .setListener(new PurchasesUpdatedListener() {
                    @Override
                    public void onPurchasesUpdated(BillingResult billingResult, @Nullable List<Purchase> purchases) {
                        // your purchases update logic
                    }
                });
    }
private fun buildBilling(): QonversionBillingBuilder {
  return QonversionBillingBuilder()
    .enablePendingPurchases()
    .setChildDirected(BillingClient.ChildDirected.CHILD_DIRECTED)
    .setUnderAgeOfConsent(BillingClient.UnderAgeOfConsent.UNSPECIFIED)
    .setListener { billingResult, purchases ->
      // your purchases update logic
                  }
}

Initializing Qonversion SDK

To enable the auto-tracking mode put these parameters to the Qonversion initialize method:

  1. ApplicationContext
  2. Your Qonversion API key.
  3. Your side UserID
  4. Instance of QonversionBillingBuilder from the Step 2.
  5. Auto-tracking - Boolean parameter put it to TRUE
public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        QonversionBillingBuilder billingBuilder = buildBilling();
        Qonversion.initialize(this, "qonversion_project_key", "yourSideUserID", billingBuilder, true);
}
class App : Application() {

    override fun onCreate() {
        super.onCreate()
        val billingBuilder = buildBilling()
        Qonversion.initialize(this, BuildConfig.QONVERSION_API_KEY, "yourSideUserID", billingBuilder, true)
    }
}

Get your Qonversion Project Key
Read more about user identifiers here

Use Qonversion Billing instead of Google BillingClient

You need to use the Qonversion Billing instance to work further with the SDK in the auto-tracking mode. It is similar to the interface and methods of Google BillingClient.

Just call Qonversion.instance?.billingClient and use the Qonversion Billing in the same way as the Google BillingClient.

📘

For more information, check the example app in the repo ManualTrackingActivity
and ManualTrackingActivityKt.

Updated 14 days ago


What's Next

Using the SDKs

Android SDK


Install Qonversion Android SDK to implement in-app subscriptions, validate user receipts, get subscription analytics, and 3-rd party integrations.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.