Present Paywall Builder paywalls in Observer mode in Android SDK
If you’ve created a flow or paywall using the Flow Builder or Paywall Builder, you don’t need to worry about rendering it in your mobile app code to display it to the user. Such a flow or paywall contains both what should be shown within it and how it should be shown.
This section refers to Observer mode only. If you do not work in the Observer mode, refer to the Android - Present flows & paywalls topic instead.
Before you start presenting flows (Click to Expand)
- Set up initial integration of Adapty with the Google Play.
- Install and configure Adapty SDK. Make sure to set the
observerModeparameter totrue. Refer to our framework-specific instructions for Android. - Create products in the Adapty Dashboard.
- Configure flows or paywalls in the builders and assign products to them.
- Create placements and assign your flows or paywalls to them in the Adapty Dashboard.
- Fetch flows and their configuration in your mobile app code.
- Implement the
AdaptyUiObserverModeHandler.
The onPurchaseInitiated event will inform you that the user has initiated a purchase. You can trigger your custom purchase flow in response to this callback:
To handle restores in Observer mode, override getRestoreHandler(). By default it returns null, which uses Adapty’s built-in Adapty.restorePurchases() flow. To provide your own restore implementation:
Remember to invoke the following callbacks to notify AdaptyUI about the purchase or restore process. This is necessary for proper flow behavior, such as showing the loader:
| Callback | Description |
|---|---|
| onStartPurchase() | The callback should be invoked to notify AdaptyUI that the purchase is started. |
| onFinishPurchase() | The callback should be invoked to notify AdaptyUI that the purchase is finished. |
| onStartRestore() | Optional. The callback can be invoked to notify AdaptyUI that the restore is started. |
| onFinishRestore() | Optional. The callback can be invoked to notify AdaptyUI that the restore is finished. |
- In order to display the visual flow on the device screen, you must first configure it.
Request parameters:
| Parameter | Presence | Description |
|---|---|---|
| flowConfiguration | required | Supply an AdaptyUI.FlowConfiguration object containing visual details of the flow. Use the AdaptyUI.getFlowConfiguration(flow) method to load it. Refer to Fetch the view configuration topic for more details. |
| products | optional | Provide an array of AdaptyPaywallProduct to optimize the display timing of products on the screen. If null is passed, AdaptyUI will automatically fetch the required products. |
| eventListener | optional | Provide an AdaptyFlowEventListener to observe flow events. Extending AdaptyFlowDefaultEventListener is recommended for ease of use. Refer to Handle flow & paywall events topic for more details. |
| insets | optional | Insets are the spaces around the flow that prevent tapable elements from getting hidden behind system bars. Default: Unspecified, which lets Adapty adjust the insets automatically. See Change flow insets. |
| customAssets | optional | Pass an AdaptyCustomAssets object to replace images and videos in your flow or paywall at runtime. Refer to Customize assets for more details. |
| tagResolver | optional | Use AdaptyUiTagResolver to resolve custom tags within the flow text. This resolver takes a tag parameter and resolves it to a corresponding string. Refer to Custom tags in Paywall Builder topic for more details. |
| observerModeHandler | required for Observer mode | The AdaptyUiObserverModeHandler you’ve implemented in the previous step. |
Don’t forget to associate paywalls to purchase transactions. Otherwise, Adapty will not determine the source flow of the purchase.