Showing Paywalls
At the heart of Superwall's SDK lies Superwall.shared.register(event:params:handler:feature:)
.
This allows you to register an event to access a feature that may or may not be paywalled later in time. It also allows you to choose whether the user can access the feature even if they don't make a purchase.
Here's an example.
With Superwall

func pressedWorkoutButton() {
// remotely decide if a paywall is shown and if
// navigation.startWorkout() is a paid-only feature
Superwall.shared.register(event: "StartWorkout") {
navigation.startWorkout()
}
}
- (void)pressedWorkoutButton {
// remotely decide if a paywall is shown and if
// navigation.startWorkout() is a paid-only feature
[[Superwall sharedInstance] registerWithEvent:@"StartWorkout" params:nil handler:nil feature:^{
[navigation startWorkout];
}];
}
Without Superwall

func pressedWorkoutButton() {
if (user.hasActiveSubscription) {
navigation.startWorkout()
} else {
navigation.presentPaywall() { result in
if (result) {
navigation.startWorkout()
} else {
// user didn't pay, developer decides what to do
}
}
}
}
- (void)pressedWorkoutButton {
if (user.hasActiveSubscription) {
[navigation startWorkout];
} else {
[navigation presentPaywallWithCompletion:^(BOOL result) {
if (result) {
[navigation startWorkout];
} else {
// user didn't pay, developer decides what to do
}
}];
}
}
How it works:
You can configure "StartWorkout"
to present a paywall by creating a campaign, adding the event, and adding a rule in the dashboard.
- The SDK retrieves your campaign settings from the dashboard on app launch.
- When an event is called that belongs to a campaign, rules are evaluated on device and the user enters an experiment — this means there's no delay between registering an event and presenting a paywall.
- If it's the first time a user is entering an experiment, a paywall is decided for the user based on the percentages you set in the dashboard
- Once a user is assigned a paywall for a rule, they will continue to see that paywall until you remove the paywall from the rule or reset assignments to the paywall.
- After the paywall is closed, the Superwall SDK looks at the Feature Gating value associated with your paywall, configurable from the paywall editor under General > Advanced > Feature Gating (more on this below)
- If the paywall is set to Non Gated, the
feature:
closure onregister(event: ...)
gets called when the paywall is dismissed (whether they paid or not) - If the paywall is set to Gated, the
feature:
closure onregister(event: ...)
gets called only if the user is already paying or if they begin paying.
- If the paywall is set to Non Gated, the
- If no paywall is configured, the feature gets executed immediately without any additional network calls.
Given the low cost nature of how register works, we strongly recommend registering all core functionality in order to remotely configure which features you want to gate – without an app update.
// on the welcome screen
func pressedSignUp() {
Superwall.shared.register(event: "SignUp") {
navigation.beginOnboarding()
}
}
// in another view controller
func pressedWorkoutButton() {
Superwall.shared.register(event: "StartWorkout") {
navigation.startWorkout()
}
}
// In the Welcome screen view controller
- (void)pressedSignUp {
[[Superwall sharedInstance] registerWithEvent:@"SignUp" params:nil handler:nil feature:^{
[navigation beginOnboarding];
}];
}
// In another view controller
- (void)pressedWorkoutButton {
[[Superwall sharedInstance] registerWithEvent:@"StartWorkout" params:nil handler:nil feature:^{
[navigation startWorkout];
}];
}
Feature Gating from the Paywall Editor
Paywall Editor > General > Advanced > Feature Gating
Feature gating allows your team to retroactively decide if this paywall is Gated or Non Gated
Type | Behavior | Example |
---|---|---|
Non Gated (default) | Show Paywall → Execute Feature | When "Sign Up" button is pressed, show a paywall, then continue onboarding once the paywall is dismissed. |
Gated | Show Paywall → Is user paying? If Yes → Execute Feature If No → Do Nothing | When "Start Workout" button is pressed, show a paywall, then continue once the paywall is dismissed only if the user subscribes. |

Remember, the feature is always executed if
- No campaign is configured for the event
- The user is already paying
Automatically Registered Events
The SDK automatically registers some internal events which can be used to present paywalls:
app_install
app_launch
deepLink_open
session_start
Register. Everything.
To provide your team with ultimate flexibility, we recommend registering all of your analytics events, even if you don't pass feature blocks through. This way you can retroactively add a paywall almost anywhere – without an app update!
If you're already set up with an analytics provider, you'll typically have an Analytics.swift
singleton (or similar) to disperse all your events from. Here's how that file might look:
import SuperwallKit
import Mixpanel
import Firebase
final class Analytics {
static var shared = Analytics()
func track(
event: String,
properties: [String: Any]
) {
// Superwall
Superwall.shared.register(event: event, params: properties)
// Firebase (just an example)
Firebase.Analytics.logEvent(event, parameters: properties)
// Mixpanel (just an example)
Mixpanel.mainInstance().track(event: eventName, properties: properties)
}
}
// And thus ...
Analytics.shared.track(
event: "workout_complete",
properties: ["total_workouts": 17]
)
// ... can now be turned into a paywall moment :)
Need to know if a paywall will show beforehand?
In some circumstances, you might like to if a particular event will present a paywall. To do this, you can use
Superwall.shared.getPresentationResult(forEvent:params:)
.
Updated 17 days ago