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 loadingColor: Int? = null // @ColorRes
var optimisticLoading: Boolean = false
var timeoutAfter: Duration? = null
var onBackPressed: ((PaywallInfo?) -> Boolean)? = null
enum class PresentationHost { ACTIVITY, IN_WINDOW }
var presentationHost: PresentationHost = PresentationHost.ACTIVITY
}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",
)
loadingColor = R.color.brand_purple
optimisticLoading = false
timeoutAfter = null
onBackPressed = { paywallInfo ->
// Custom back button handling
// Return true to consume the back press. Returning false forwards it to
// the paywall, which navigates back one page or closes itself. Republish
// paywalls built before back_button_input support to use this behavior.
false
}
}
val options = SuperwallOptions().apply {
paywalls = paywallOptions
}
Superwall.configure(
applicationContext = 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.
In-window presentation (experimental, 2.8.6+)
By default, the SDK presents paywalls in its own SuperwallPaywallActivity. Set presentationHost to IN_WINDOW to show the paywall over the presenting Activity's window, leaving that Activity uncovered. All presentation styles are supported. This mode can help game-engine hosts such as Unity keep running while a paywall is visible. If the host Activity is destroyed while the paywall is shown, including by a configuration change it does not handle itself, the paywall is dismissed. This option is experimental and may change or be removed in a future release.
val options = SuperwallOptions().apply {
paywalls.presentationHost = PaywallOptions.PresentationHost.IN_WINDOW
}
Superwall.configure(
applicationContext = this,
apiKey = "pk_your_api_key",
options = options,
)Related
How is this guide?