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 com.superwall.sdk.analytics.Tier
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 preloadDeviceOverrides: Map<Tier, Boolean> = emptyMap()
    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
    preloadDeviceOverrides = mapOf(
        Tier.ULTRA_LOW to false,
        Tier.LOW to false,
    )
    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,
)

preloadDeviceOverrides is useful when you want to keep preloading enabled by default but disable it on lower-end devices. Tiers you do not specify continue to use the shouldPreload value.

How is this guide?

On this page