Observer Mode
If you have a purchase system and/or want to test Apphud without full integration, you can use Observer mode.
Observer Mode
If you are planning to use your own purchase code, consider integrating Apphud SDK in Observer (Analytics) mode. In this case you are responsible for displaying products, making purchases and finishing / acknowleding transactions, and Apphud SDK will only track successful purchases.
Important Note
Keep in mind, that you are responsible for acknowledging or consuming all purchases on Android, and finishing transactions on iOS while using Apphud SDK in Observer mode.
Apphud.start(apiKey: "YOUR_API_KEY", observerMode: true)
[Apphud startWithApiKey:@"YOUR_API_KEY" userID:nil observerMode:YES];
// Initialization on Android doesn't differ
Apphud.start(this, "YOUR_API_KEY")
await Apphud.start(apiKey: "YOUR_API_KEY", observerMode: true);
await ApphudSdk.start({ apiKey: "YOUR_API_KEY", observerMode: true });
iOS
All you have to do is passing observerMode: true
parameter when initializing SDK.
That is all you have to do with Apphud SDK on iOS.
Android
Initialization on Android is the same as non-observer mode. See this guide for details.
However, you are responsible for submitting purchases to Apphud after successful purchase and restore.
To track successful purchase call:
Apphud.trackPurchase(purchase, productDetails, offerIdToken)
Missing "trackPurchases" method?
Apphud.trackPurchases()
method is new, so if your SDK version is missing it, consider callingApphud.syncPurchases
instead. Or update to the latest SDK version.
Next, when user taps on "Restore Purchases" button in your app's UI, consider calling syncPurchases
method:
Apphud.syncPurchases()
await Apphud.syncPurchases();
await ApphudSdk.syncPurchases();
Pass Obfuscated Account ID (Android)
It is highly recommended to set up obfuscatedAccountId
in BillingFlowParams
object:
BillingFlowParams.newBuilder().setObfuscatedAccountId(Apphud.deviceId())
Note
Don't forget to set up the App Store / Google server notifications in Apphud settings in order to get real time updates.
Observer Mode vs Full Mode: Features Comparison
Advantages | Observer Mode | Full Mode |
---|---|---|
Integrations | Yes* | Yes* |
Analytics | Yes | Yes |
Paywalls management | No | Yes |
Experiments (A/B Tests) | Yes*** | Yes |
Rules (iOS) | Yes** | Yes** |
Web2App | Yes | Yes |
* requires few more lines of code, like User ID Matching. See documentation of your integration.
** requires push notification handling. See here.
*** requires additional client functions.
A/B Experiments in Observer Mode
If you want to use A/B experiments while running SDK in Observer Mode
you should manually send paywall identifier to Apphud using this method. See code example below regarding where to call this method.
// You must call this method right before your own purchase method.
Apphud.willPurchaseProductFromPaywall("main_paywall")
// Your purchase flow
// Call this method with Paywall Identifier right after successful purchase
Apphud.trackPurchase(purchase, details, paywallIdentifier)
// If trackPurchase is missing in your SDK version, update the SDK or call:
// Apphud.syncPurchases(paywallIdentifier: "your_paywall_identifier")
await Apphud.syncPurchases(paywallIdentifier: "main_paywall")
Updated about 1 year ago