Superwall

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

public func getPresentationResult(
  forPlacement placement: String,
  params: [String: Any]? = nil
) async -> PresentationResult
public func getPresentationResult(
  forPlacement placement: String,
  params: [String: Any]? = nil,
  completion: @escaping (PresentationResult) -> Void
)

Parameters

NameTypeDescription
placementStringThe placement you want to evaluate.
params[String: Any]?Optional parameters passed to audience filters. Keys starting with $ are reserved by Superwall and removed. Nested dictionaries and arrays are ignored. Defaults to nil.

Returns / State

Returns a PresentationResult, which can be:

  • .placementNotFound – The placement name is not attached to any campaign.
  • .noAudienceMatch – No audience matched, so nothing would be shown.
  • .paywall(experiment: Experiment) – A paywall would be shown; the experiment contains assignment info.
  • .holdout(experiment: Experiment) – The user would be held out of the paywall for the experiment.
  • .paywallNotAvailable – The SDK could not show a paywall (for example, no window to present from).

Usage

let result = await Superwall.shared.getPresentationResult(
  forPlacement: "premium_feature",
  params: ["source": "settings"]
)

switch result {
case .paywall(let experiment):
  analytics.log("Paywall would show", metadata: [
    "experimentId": experiment.id,
    "groupId": experiment.groupId
  ])
case .holdout(let experiment):
  showHoldoutBadge(for: experiment)
case .noAudienceMatch:
  unlockFeature()
case .placementNotFound:
  assertionFailure("Missing campaign setup")
case .paywallNotAvailable:
  fallbackToDefaultFlow()
}
Superwall.shared.getPresentationResult(forPlacement: "premium_feature") { result in
  guard case .paywall(let experiment) = result else {
    return
  }

  // Update UI with experiment metadata while keeping the user on the current screen
  self.paywallExperimentId = experiment.id
}

How is this guide?

Edit on GitHub