handleDeepLink()
Handles a deep link.
Deprecated SDK
We strongly recommend migrating to the new Superwall Expo SDK, see our migration guide for details.
Purpose
Handles a deep link that may be related to Superwall functionality (e.g., promotional links, paywall deep links).
Signature
async handleDeepLink(url: string): Promise<boolean>Parameters
Prop
Type
Returns / State
Returns a Promise that resolves to a boolean indicating whether the deep link was handled by Superwall. Returns true if Superwall handled the link, false otherwise.
Usage
// In your deep link handler
const url = "https://your-app.com/paywall?placement=onboarding"
const wasHandled = await Superwall.shared.handleDeepLink(url)
if (!wasHandled) {
// Handle other deep links in your app
handleOtherDeepLink(url)
}Integration
Typically, you'll call this method from your app's deep link handler:
import { Linking } from "react-native"
// Handle initial URL (if app was opened via deep link)
Linking.getInitialURL().then((url) => {
if (url) {
Superwall.shared.handleDeepLink(url)
}
})
// Handle deep links while app is running
Linking.addEventListener("url", (event) => {
Superwall.shared.handleDeepLink(event.url)
})Web checkout and cold launches
Keep both calls. After a web checkout purchase, the browser opens your app with a redemption link. That link is how the SDK learns the user paid: handleDeepLink redeems it, then calls willRedeemLink and didRedeemLink on your delegate.
If iOS or Android closed your app while the user was in the browser, the link launches the app from scratch. React Native doesn't send a url event for the link that launched the app, so only Linking.getInitialURL() gives it to you. If you don't pass that URL to handleDeepLink, the purchase isn't redeemed on launch. It only reaches the app later, when entitlements sync, and in the meantime a paywall can show again to a user who already paid.
Call getInitialURL() once, after you configure Superwall, and register the url listener for links that arrive while the app is running.
The React Native SDK doesn't support the checkout page, which needs iOS SDK 4.18.0 or later. To use it, migrate to the Expo SDK. Its SuperwallProvider forwards the launch URL for you. See Forward the launch URL for web checkout.
Related
SuperwallDelegate.paywallWillOpenDeepLink- Delegate method called before opening a deep link
How is this guide?