Observer Mode

Learn how to use Adapty Android SDK in Observer mode along with existing purchase infrastructure

If you have a functioning subscription system and want to give Adapty SDK a quick try, you can use Observer mode. With just one line of code you can:

At any purchase or restore in your application, you need to call .restorePurchases() method to record the action in Adapty.

Adapty.restorePurchases { purchaserInfo, googleValidationResultList, error ->
    if (error == null) {
        // successful restore
    }
}

❗️

When running in Observer mode, Adapty SDK won't consume or acknowledge any purchases, so make sure you're handling it. Otherwise, the purchases will be automatically refunded after 3 days.

A/B tests analytics

In Observer mode, Adapty SDK doesn't know, where the purchase was made from. If you display products using our Paywalls or A/B Tests, you can manually assign variation to the purchase. After doing this, you'll be able to see metrics in Adapty Dashboard.

Adapty.setTransactionVariationId(transactionId, variationId) { error ->
    if (error == null) {
        // success
    }
}

Request parameters:

  • Transaction Id (required): a string identifier (purchase.getOrderId()) of the purchase, where the purchase is an instance of the billing library Purchase class.
  • Variation Id (required): a string identifier of variation. You can get it using variationId property of PaywallModel.

Did this page help you?