Flutter – 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:

Important

🚧

When running in Observer mode, Adapty SDK won't close any transactions, so make sure you're handling it.

Activating Observer Mode

Adapty SDK will automatically collect all transactions and will be sending subscription events. To turn on Observer mode, just add the AdaptyObserverMode key to Adapty-Info.plist and AndroidManifest.xml

<dict>
    ...
    <key>AdaptyPublicSdkKey</key>
    <string>PUBLIC_SDK_KEY</string>
    <key>AdaptyObserverMode</key>
		<true/>
</dict>
<application ...>
       ...
       <meta-data
              android:name="AdaptyPublicSdkKey"
              android:value="PUBLIC_SDK_KEY"/>
                
       <meta-data
              android:name="AdaptyObserverMode"
              android:value="true"/>
</application>

📘

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

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.

final transactionId = transaction.transactionIdentifier
final variationId = paywall.variationId

try {
  await Adapty().setVariationId('transaction_id', variationId);
} on AdaptyError catch (adaptyError) {
  // handle the error
} catch (e) {
}

Request parameters:

  • variationId (required): a string identifier of variation. You can get it using variationId property of Paywall
  • transactionId (required): a string identifier of your purchased transaction SKPaymentTransaction for iOS