Superwall

PaywallOptions

Configuration for paywall presentation and behavior in the Superwall Android SDK.

PaywallOptions is provided via the paywalls property on SuperwallOptions and is passed to the SDK when you call configure.

Purpose

Customize how paywalls look and behave, including preload behavior, alerts, dismissal, and haptics.

Signature

import kotlin.time.Duration

class PaywallOptions {
    var isHapticFeedbackEnabled: Boolean = true

    class RestoreFailed {
        var title: String = "No Subscription Found"
        var message: String = "We couldn't find an active subscription for your account."
        var closeButtonTitle: String = "Okay"
    }
    var restoreFailed: RestoreFailed = RestoreFailed()

    var shouldShowPurchaseFailureAlert: Boolean = true
    var shouldPreload: Boolean = true
    var useCachedTemplates: Boolean = false
    var automaticallyDismiss: Boolean = true

    enum class TransactionBackgroundView { SPINNER }
    var transactionBackgroundView: TransactionBackgroundView? = TransactionBackgroundView.SPINNER

    var overrideProductsByName: Map<String, String> = emptyMap()
    var optimisticLoading: Boolean = false
    var timeoutAfter: Duration? = null
    var onBackPressed: ((PaywallInfo?) -> Boolean)? = null
}

Parameters

Prop

Type

Usage

val paywallOptions = PaywallOptions().apply {
    isHapticFeedbackEnabled = true
    shouldShowPurchaseFailureAlert = false
    shouldPreload = true
    useCachedTemplates = false
    automaticallyDismiss = true
    transactionBackgroundView = PaywallOptions.TransactionBackgroundView.SPINNER
    overrideProductsByName = mapOf(
        "primary" to "com.example.premium_monthly",
        "tertiary" to "com.example.premium_annual",
    )
    optimisticLoading = false
    timeoutAfter = null
    onBackPressed = { paywallInfo ->
        // Custom back button handling
        // Return true to consume the back press, false to use SDK default
        false
    }
}

val options = SuperwallOptions().apply {
    paywalls = paywallOptions
}

Superwall.configure(
    application = this,
    apiKey = "pk_your_api_key",
    options = options,
)

How is this guide?

Edit on GitHub