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
}

Parameters

PropertyTypeDescription
isHapticFeedbackEnabledBooleanEnables haptic feedback when users purchase/restore, open links, or close the paywall. Defaults to true.
restoreFailedRestoreFailedMessaging for the restore-failed alert.
restoreFailed.titleStringTitle for restore-failed alert. Defaults to "No Subscription Found".
restoreFailed.messageStringMessage for restore-failed alert. Defaults to "We couldn't find an active subscription for your account."
restoreFailed.closeButtonTitleStringClose button title for restore-failed alert. Defaults to "Okay".
shouldShowPurchaseFailureAlertBooleanShows an alert after a purchase fails. Set to false if you handle failures via a PurchaseController. Defaults to true.
shouldPreloadBooleanPreloads and caches trigger paywalls and products during SDK initialization. Set to false for just-in-time loading. Defaults to true.
useCachedTemplatesBooleanLoads paywall template websites from disk when available. Defaults to false.
automaticallyDismissBooleanAutomatically dismisses the paywall on successful purchase or restore. Defaults to true.
transactionBackgroundViewTransactionBackgroundView?View shown behind the system payment sheet during a transaction. Use null for no view. Defaults to .SPINNER.
overrideProductsByNameMap<String, String>Overrides products on all paywalls using name→identifier mapping (e.g., "primary""com.example.premium_monthly").
optimisticLoadingBooleanHides shimmer optimistically. Defaults to false.
timeoutAfterDuration?Duration until a paywall timeout is invoked. When not using fallback loading, setting this triggers a timeout instead of retrying.

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
}

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

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

How is this guide?