I've set up universal links with the Branch SDK. The links are opening the app correctly, and application:continueUserActivity:restorationHandler:
is called, but not `application:openURL:options:'
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
Branch.getInstance().application(app, open: url, options: options)
return true
}
The deprecated application:openURL:sourceApplications:annotation
is also not called. didFinishLaunchingWithOptions
and willFinishLaunchingWithOptions
both return true.
What could possibly causing openURL to not be called when the app opens from tapping a universal link?
Clay from Branch here.
The application:openURL:sourceApplications:annotation
function (now deprecate to application(_:open:options:)
) is actually only called in response to the old Apple Linking system of standard URI schemes.
Universal links are actually handled within the application(_:continue:restorationHandler:)
function.
// Respond to URI scheme links
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
// pass the url to the handle deep link call
Branch.getInstance().application(app, open: url, options: options)
// do other deep link routing for the Facebook SDK, Pinterest SDK, etc
return true
}
// Respond to Universal Links
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
// pass the url to the handle deep link call
Branch.getInstance().continue(userActivity)
return true
}
Your deep link handling should mostly be dealt with in your handler callback:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let branch: Branch = Branch.getInstance()
branch?.initSession(launchOptions: launchOptions, deepLinkHandler: { params, error in
if error == nil {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
print("params: %@", params.description)
}
})
return true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With