Using Superwall Deep Links
How to use Superwall Deep Links to trigger paywalls or custom in-app behavior.
A Superwall Deep Link is a URL hosted at https://<subdomain>.superwall.app/app-link/... that opens your app to trigger a paywall as configured on the Superwall dashboard, or custom in-app behavior via the Superwall delegate.
Prerequisites
- Set up deep link handling
- Create a Web Checkout app, even if you do not plan to charge through Web Checkout, this provisions the
*.superwall.appdomain that powers Superwall Deep Links.
Handling incoming links
- Always call
handleDeepLinkfirst. It returnstruewhen the SDK recognizes the URL and plans to take over presentation, orfalsewhen you should continue routing inside your own app. - When a recognized link arrives before
Superwall.configure(...)finishes, the SDK caches it and replays it immediately after configuration completes, so it is safe to forward links during cold launch. - If the return value is
false, continue with your normal router—those links are not associated with any Superwall experience.
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
let handled = Superwall.handleDeepLink(url)
if handled {
return true
}
return routeInternally(url)
}Link formats and campaigns
Deep link URLs are hosted at https://<subdomain>.superwall.app/app-link/..., you can have anything after the /app-link/ path, including query parameters. These values will be availble to you in audience filters on the Superwall dashboard, or in the handleSuperwallDeepLink delegate method.
final class PaywallDelegate: SuperwallDelegate {
func handleSuperwallDeepLink(
_ url: URL,
pathComponents: [String],
queryParameters: [String: String]
) {
guard let head = pathComponents.first else { return }
switch head {
case "campaign":
if pathComponents.count > 1 {
routeToCampaignDetail(id: pathComponents[1])
}
default:
break
}
}
}Keep your own routing logic in place for non-Superwall URLs and for any additional behaviors you want to stack on top of Superwall’s default presentation flow.
How is this guide?
Edit on GitHub