Module 4 — Forwarding links to the SDK
When iOS delivers a link to your app, you forward it to the SDK. Pick the path that matches your app's lifecycle. Each is one or two lines.
SwiftUI (iOS 14+)
Add one modifier to your root view:
@main
struct MyApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
.paylisherDeepLinks() // wires onOpenURL + onContinueUserActivity to the SDK
}
}
}
paylisherDeepLinks() is equivalent to wiring both onOpenURL (custom schemes) and onContinueUserActivity(NSUserActivityTypeBrowsingWeb) (Universal Links).
Targeting iOS 13?
paylisherDeepLinks()and the SwiftUIApplifecycle are iOS 14+. Skip the modifier and use the UIKit or SceneDelegate forwarding below — the SDK's forwarding methods all run on iOS 13.
UIKit / AppDelegate
// Custom scheme — iOS calls this on cold launch too, so it's the single entry point.
func application(_ app: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
return PaylisherSDK.shared.handleDeepLink(url)
}
// Universal Links
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
return PaylisherSDK.shared.handleUserActivity(userActivity)
}
Don't also process
launchOptions[.url]. iOS already callsopen:on cold launch; handling both processes the same link twice (you'll see a duplicateDeep Link Openedevent).
SceneDelegate (iOS 13+)
The recommended path when you target iOS 13 with the UIKit scene lifecycle:
// Custom scheme (warm)
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
PaylisherSDK.shared.handleURLContexts(URLContexts)
}
// Universal Link (warm)
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
_ = PaylisherSDK.shared.handleUserActivity(userActivity)
}
// Cold start: a link that launched the app arrives in connectionOptions.
func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
PaylisherSDK.shared.handleURLContexts(connectionOptions.urlContexts)
connectionOptions.userActivities.forEach { _ = PaylisherSDK.shared.handleUserActivity($0) }
}
Which method handles what
| Source | Method |
|---|---|
| Custom scheme (AppDelegate) | handleDeepLink(_ url:) |
| Custom scheme (SceneDelegate) | handleURLContexts(_:) |
| Universal Link | handleUserActivity(_:) |
| Everything (SwiftUI) | .paylisherDeepLinks() |
The SDK normalizes all of them into the same PaylisherDeepLink — your router never has to know which one fired.
Next: Module 5 — Routing →