Android - Observer mode

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 { result ->
    when (result) {
        is AdaptyResult.Success -> {
            // successful restore
        }
        is AdaptyResult.Error -> {
            val error = result.error
            // handle the error
        }
    }
}
Adapty.restorePurchases(result -> {
    if (result instanceof AdaptyResult.Success) {
        // successful restore
    } else if (result instanceof AdaptyResult.Error) {
        AdaptyError error = ((AdaptyResult.Error) result).getError();
        // handle the error
    }
});

❗️

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.setVariationId(transactionId, variationId) { error ->
    if (error == null) {
        // success
    }
}
Adapty.setVariationId(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 AdaptyPaywall.