getPaywall()
A function that retrieves a PaywallViewController for custom presentation.
You're responsible for ensuring the returned PaywallViewController is no longer presented or embedded in a view after the user has moved past the paywall. The app may crash if you or the SDK attempts to present the same PaywallViewController instance again from elsewhere. Be especially careful when mixing register() and getPaywall(), which is not recommended.
The remotely configured presentation style is ignored when using this method. You must handle presentation styling programmatically.
Purpose
Retrieves a PaywallViewController that you can present however you want, bypassing Superwall's automatic presentation logic.
Signature
// Async/await version
@MainActor
public func getPaywall(
forPlacement placement: String,
params: [String: Any]? = nil,
paywallOverrides: PaywallOverrides? = nil,
delegate: PaywallViewControllerDelegate
) async throws -> PaywallViewController
// Completion handler version
public func getPaywall(
forPlacement placement: String,
params: [String: Any]? = nil,
paywallOverrides: PaywallOverrides? = nil,
delegate: PaywallViewControllerDelegate,
completion: @escaping (PaywallViewController?, PaywallSkippedReason?, Error?) -> Void
)Parameters
Prop
Type
Returns / State
Returns a PaywallViewController that you can present. If presentation should be skipped, throws a PaywallSkippedReason error.
Usage
Using async/await:
Task {
do {
let paywallViewController = try await Superwall.shared.getPaywall(
forPlacement: "premium_feature",
params: ["source": "settings"],
delegate: self
)
present(paywallViewController, animated: true)
} catch let reason as PaywallSkippedReason {
print("Paywall skipped: \(reason)")
} catch {
print("Error getting paywall: \(error)")
}
}Using completion handler:
Superwall.shared.getPaywall(
forPlacement: "premium_feature",
delegate: self
) { paywall, skippedReason, error in
if let paywall = paywall {
present(paywall, animated: true)
} else if let reason = skippedReason {
print("Paywall skipped: \(reason)")
} else if let error = error {
print("Error: \(error)")
}
}How is this guide?
Edit on GitHub