getPresentationResult()
Check the outcome of a placement without presenting a paywall.
Purpose
Retrieves the presentation result for a placement without presenting the paywall. Call this when you need to know whether a placement would show a paywall, send the user to a holdout, or fail due to missing configuration before you decide how to render UI.
Signature
suspend fun Superwall.getPresentationResult(
placement: String,
params: Map<String, Any>? = null,
): Result<PresentationResult>fun Superwall.getPresentationResultSync(
placement: String,
params: Map<String, Any>? = null,
): Result<PresentationResult>getPresentationResultSync blocks the calling thread. Prefer the suspend function inside a coroutine whenever possible.
Parameters
| Name | Type | Description |
|---|---|---|
placement | String | The placement to evaluate. |
params | Map<String, Any>? | Optional custom parameters that feed audience filters. Keys starting with $ are dropped by the SDK. Nested maps or lists are ignored. Defaults to null. |
Returns / State
Returns a Kotlin Result<PresentationResult>.
- On success, the wrapped
PresentationResultcan be:PresentationResult.PlacementNotFound– Placement is missing from any live campaign.PresentationResult.NoAudienceMatch– No audience matched, so nothing would show.PresentationResult.Paywall(experiment)– A paywall would be presented; inspect theexperiment.PresentationResult.Holdout(experiment)– The user is in a holdout group for that experiment.PresentationResult.PaywallNotAvailable– The SDK could not present (no activity, already showing, offline, etc.).
- On failure, the
Resultcontains the thrown exception (for example, the SDK is not configured yet). Inspect it withexceptionOrNull()oronFailure.
Usage
lifecycleScope.launch {
val result = Superwall.instance.getPresentationResult(
placement = "premium_feature",
params = mapOf("source" to "settings")
)
result
.onSuccess { presentation ->
when (presentation) {
is PresentationResult.Paywall -> {
logExperiment(presentation.experiment)
showLockedState()
}
is PresentationResult.Holdout -> showHoldoutBanner()
is PresentationResult.NoAudienceMatch -> unlockFeature()
is PresentationResult.PlacementNotFound -> Timber.w("Missing placement configuration")
is PresentationResult.PaywallNotAvailable -> showOfflineMessage()
}
}
.onFailure { error ->
Timber.e(error, "Unable to fetch presentation result")
}
}// Blocking usage (for example, inside a worker)
val result = Superwall.instance.getPresentationResultSync("premium_feature")
val presentation = result.getOrNull() ?: returnRelated
register()– Registers a placement and may present a paywall.SuperwallDelegate– Receive callbacks when paywalls are presented.
How is this guide?
Edit on GitHub