Android - Present Paywall Builder paywalls
If you've customized a paywall using the Paywall Builder, you don't need to worry about rendering it in your mobile app code to display it to the user. Such a paywall contains both what should be shown within the paywall and how it should be shown.
If you work in Observer mode, refer to the Android - Present Paywall Builder paywalls in Observer mode topic instead.
- Views
- Jetpack Compose
In order to display the visual paywall on the device screen, you must first configure it. To do this, call the method AdaptyUI.getPaywallView()
or create the AdaptyPaywallView
directly:
- Kotlin (option 1)
- Kotlin (option 2)
- Java (option 1)
- Java (option 2)
- XML
val paywallView = AdaptyUI.getPaywallView(
activity,
viewConfiguration,
products,
eventListener,
personalizedOfferResolver,
tagResolver,
timerResolver,
)
val paywallView =
AdaptyPaywallView(activity) // or retrieve it from xml
...
with(paywallView) {
showPaywall(
viewConfiguration,
products,
eventListener,
personalizedOfferResolver,
tagResolver,
timerResolver,
)
}
AdaptyPaywallView paywallView = AdaptyUI.getPaywallView(
activity,
viewConfiguration,
products,
eventListener,
personalizedOfferResolver,
tagResolver,
timerResolver
);
AdaptyPaywallView paywallView =
new AdaptyPaywallView(activity); //add to the view hierarchy if needed, or you receive it from xml
...
paywallView.showPaywall(viewConfiguration, products, eventListener, personalizedOfferResolver, tagResolver, timerResolver);
<com.adapty.ui.AdaptyPaywallView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" />
After the view has been successfully created, you can add it to the view hierarchy and display it on the screen of the device.
If you get AdaptyPaywallView
not by calling AdaptyUI.getPaywallView()
, you will also need to call the .showPaywall()
method.
In order to display the visual paywall on the device screen, you must first configure it. To do this, use this composable function:
AdaptyPaywallScreen(
viewConfiguration,
products,
eventListener,
personalizedOfferResolver,
tagResolver,
timerResolver,
)
Request parameters:
Parameter | Presence | Description |
---|---|---|
viewConfiguration | required | Supply an AdaptyUI.LocalizedViewConfiguration object containing visual details of the paywall. Use the Adapty.getViewConfiguration(paywall) method to load it. Refer to Fetch the visual configuration of paywall 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 AdaptyUiEventListener to observe paywall events. Extending AdaptyUiDefaultEventListener is recommended for ease of use. Refer to Handling paywall events topic for more details. |
personalizedOfferResolver | optional | To indicate personalized pricing (read more ), implement AdaptyUiPersonalizedOfferResolver and pass your own logic that maps AdaptyPaywallProduct to true if the product's price is personalized, otherwise false. |
tagResolver | optional | Use AdaptyUiTagResolver to resolve custom tags within the paywall 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. |
timerResolver | optional | Pass the resolver here if you are going to use custom timer functionality. |
Change paywall loading indicator color
You can override the default color of the loading indicator in the following way:
<!--your theme -->
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
<!--other attrs -->
<item name="adapty_progressIndicatorColor">@color/yourColor</item>
</style>