Visual paywalls

Learn how to show visual paywalls using Adapty Android SDK.

🚧

This functionality is beta stage right now. Contact support for early access.

Adapty allows you remotely configure paywall through dashboard that could be displayed in your app without any client side updates.

At first place you need to configure your paywall in Adapty dashboard and after that you will be able to use them inside your app.

Show paywall: default way

To show visual paywall as a modal screen, you need to call .showVisualPaywall() method.

Adapty.showVisualPaywall(activity, paywall)

Request parameters:

By default, the orientation of visual paywall shown in a modal way is unspecified. If you want to lock it, say, to portrait, you can override it in your AndroidManifest.xml:

<activity
    android:name="com.adapty.visual.VisualPaywallActivity"
    android:screenOrientation="portrait" />

Show paywall: manual way

Also you can show visual paywall manually, adding VisualPaywallView to your custom screen. In this case you will need to call the following method:

visualPaywallView.showPaywall(paywall, paddingTop, paddingBottom)

Request parameters:

  • paywall (required): PaywallModel which needs to be shown.
  • paddingTop and paddingBottom (both optional, default is 0): Integer, height of the top and bottom system bars in pixels. Needed in case your Activity is fullscreen, so that system bars don't overlap the content.

Close paywall (only for default way)

To close modal visual paywall, you need to call .closeVisualPaywall() method.

Adapty.closeVisualPaywall()

🚧

Make sure you use this method only if paywall was shown through Adapty.showVisualPaywall() method.
If you show your paywall in any other way, this method doesn't work, and you should close the paywall manually like you'd do it with any other screen.

VisualPaywallListener

VisualPaywallListener allows you to handle actions performed by the user in the paywall

Adapty.setVisualPaywallListener(object : VisualPaywallListener {
    override fun onPurchased(
        purchaserInfo: PurchaserInfoModel?,
        purchaseToken: String?,
        googleValidationResult: GoogleValidationResult?,
        product: ProductModel,
        modalActivity: VisualPaywallActivity?
    ) {
        // handle successful purchase and close paywall if needed
    }
    override fun onPurchaseFailure(
        product: ProductModel,
        error: AdaptyError,
        modalActivity: VisualPaywallActivity?
    ) {
        // handle purchase error and close paywall if needed
    }
    override fun onRestorePurchases(
        purchaserInfo: PurchaserInfoModel?,
        googleValidationResultList: List<GoogleValidationResult>?,
        error: AdaptyError?,
        modalActivity: VisualPaywallActivity?
    ) {
        // handle purchases restore event
    }
    override fun onCancel(modalActivity: VisualPaywallActivity?) {
        // close paywall by SDK method if it was shown modally
        // or handle closing in any other way
    }
})

🚧

modalActivity in the callbacks from VisualPaywallListener is not null only if you show the paywall calling Adapty.showVisualPaywall(). In this case you can close the paywall calling either modalActivity?.close() or Adapty.closeVisualPaywall(), in any other case, if you need to close the paywall, you should do it manually.


Did this page help you?