Showing Paywalls
At the heart of Superwall’s SDK lies Superwall.shared.register(placement:params:handler:feature:)
.
This allows you to register a placement 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
Without Superwall
How registering placements presents paywalls
You can configure "StartWorkout"
to present a paywall by creating a campaign, adding the placement, and adding a paywall to an audience in the dashboard.
- The SDK retrieves your campaign settings from the dashboard on app launch.
- When a placement is called that belongs to a campaign, audiences are evaluated on device and the user enters an experiment — this means there’s no delay between registering a placement 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 an audience, they will continue to see that paywall until you remove the paywall from the audience 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 > Feature Gating (more on this below)
- If the paywall is set to Non Gated, the
feature:
closure onregister(placement: ...)
gets called when the paywall is dismissed (whether they paid or not) - If the paywall is set to Gated, the
feature:
closure onregister(placement: ...)
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.
Automatically Registered Placements
The SDK automatically registers some internal placements which can be used to present paywalls:
app_install
app_launch
deepLink_open
session_start
transaction_abandon
transaction_fail
paywall_close
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:
Need to know if a paywall will show beforehand?
In some circumstances, you might like to know if a particular placement will present a paywall. To do this, you can use Superwall.shared.getPresentationResult(forPlacement:params:)
.