on Custom Callback
Sets the handler that will be called when the paywall requests a custom callback.
Custom callbacks allow paywalls to request arbitrary actions from the app and receive results that determine which branch (onSuccess/onFailure) executes.
Parameters
handler
A function that receives a CustomCallback containing the callback name and optional variables, and returns a CustomCallbackResult indicating success/failure with optional data.
Example:
handler.onCustomCallback { callback ->
when (callback.name) {
"validate_email" -> {
val email = callback.variables?.get("email") as? String
if (isValidEmail(email)) {
CustomCallbackResult.success(mapOf("validated" to true))
} else {
CustomCallbackResult.failure(mapOf("error" to "Invalid email"))
}
}
else -> CustomCallbackResult.failure()
}
}Content copied to clipboard