launchIfNeededWithOptions

Launch the paywall activity conditionally with the specified options.

The paywall will be displayed based on one of these conditions (exactly one must be set):

Example with entitlement check:

val options = PaywallActivityLaunchIfNeededOptions.Builder()
.setRequiredEntitlementIdentifier("premium")
.setCustomVariables(mapOf("user_name" to CustomVariableValue.String("John")))
.setPaywallDisplayCallback(object : PaywallDisplayCallback {
override fun onPaywallDisplayResult(wasDisplayed: Boolean) {
// Handle result
}
})
.build()

launcher.launchIfNeededWithOptions(options)

Example with custom condition:

val options = PaywallActivityLaunchIfNeededOptions.Builder()
.setShouldDisplayBlock { customerInfo ->
customerInfo.entitlements.active.isEmpty()
}
.setCustomVariables(mapOf("user_name" to CustomVariableValue.String("John")))
.build()

launcher.launchIfNeededWithOptions(options)

Parameters