Application: openURL: options: not called after opening a universal link

I installed universal links from the Branch SDK. The links open the application correctly, but it 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
}

      

Deprecated is application:openURL:sourceApplications:annotation

also not called. didFinishLaunchingWithOptions

and willFinishLaunchingWithOptions

both return true.

What can cause openURL not to be called when the application is opened by clicking on the universal link?

+3


source to share


1 answer


Clay from Branch is here.

The function application:openURL:sourceApplications:annotation

(now deprecated to application(_:open:options:)

) is actually only called in response to Apple's old Linking system of standard URI schemes.

Universal references are actually processed inside the function application(_:continue:restorationHandler:)

.



// 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
}

      

In the handler callback, basically handle the deep link:

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
}

      

+3


source







All Articles