gpt4 book ai didi

ios - 应用程序 :openURL:options: not called after opening universal link

转载 作者:搜寻专家 更新时间:2023-10-31 08:19:43 25 4
gpt4 key购买 nike

我已经使用 Branch SDK 设置了通用链接。链接正确打开应用程序,并且 application:continueUserActivity:restorationHandler: 被调用,但不是 `application:openURL:options:'

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
Branch.getInstance().application(app, open: url, options: options)
return true
}

已弃用的 application:openURL:sourceApplications:annotation 也不会被调用。 didFinishLaunchingWithOptionswillFinishLaunchingWithOptions 都返回 true。

当应用程序通过点击通用链接打开时,什么可能导致 openURL 不被调用?

最佳答案

粘土来自 Branch在这里。

application:openURL:sourceApplications:annotation 函数(现在弃用为 application(_:open:options:))实际上只是为了响应旧 Apple 而被调用标准URI方案的链接系统。

通用链接实际上是在 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
}

您的深层链接处理应该主要在您的处理程序回调中处理:

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
}

关于ios - 应用程序 :openURL:options: not called after opening universal link,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45381922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com