gpt4 book ai didi

iOS didFinishLaunchingWithOptions : no URL although the app is opened by tapping a link

转载 作者:行者123 更新时间:2023-11-29 00:00:22 25 4
gpt4 key购买 nike

我正在使用 Branch 处理的链接打开我的应用:

https://my.link?param=test

didFinishLaunchingWithOptions 中:

Branch.getInstance()?.initSession(launchOptions: launchOptions, andRegisterDeepLinkHandler: { params, error in
if error == nil {
if let param = params?["param"] as? String {
print(param)
}
}
}

这会在控制台中正确打印 test

但是,我之前也尝试获取 url,但尝试获取 launchOptions?[.url],结果得到 nil

那么如何获取url呢?感谢您的帮助。

最佳答案

您需要使用UIApplicationLaunchOptionsKey

试试这个:

if let url = launchOptions?[UIApplicationLaunchOptionsKey.url] as? URL {
// Your code
}
else if let activityDictionary = launchOptions?[UIApplicationLaunchOptionsKey.userActivityDictionary] as? [AnyHashable: Any] { //Universal link
for key in activityDictionary.keys {
if let userActivity = activityDictionary[key] as? NSUserActivity {
if let url = userActivity.webpageURL {
// your code
}
}
}
}

关于iOS didFinishLaunchingWithOptions : no URL although the app is opened by tapping a link,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49651160/

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