gpt4 book ai didi

ios - 通用链接、continueUserActivity 和 sourceApplication 未被调用

转载 作者:行者123 更新时间:2023-11-28 09:35:41 25 4
gpt4 key购买 nike

我终于设法建立了通用链接,如果我点击链接,它将打开我的应用程序。但它不会出现在持续的用户事件或源应用程序中。因为我想将它重定向到特定的 View Controller 。例如,如果我打开 "https://www.myWeb.com/forgotPassword",它将重定向到 forgotPasswordViewController,我需要阅读链接。

为什么它不显示在持续用户事件中?

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
print(url)
let urlHost : String = url.host as String!
print("HELLO")

let main : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let inner : ResetPasswordViewController = main.instantiateViewController(withIdentifier: "ResetPasswordViewController") as! ResetPasswordViewController
self.window?.rootViewController = inner
self.window?.makeKeyAndVisible()
return true;



}

func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
let url = userActivity.webpageURL!
print(url)
print("HELLO WORLD")
}
return true
}

这就是源应用程序发生的情况;谁能告诉我为什么会变成这样?

sourceApplication

最佳答案

已解决只是因为数据类型,我用 AnyObject 代替了 Any。但是编译器不告诉我是否不能使用 AnyObject

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
print("Continue User Activity: ")
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
let url = userActivity.webpageURL!
print(url.absoluteString)
//handle url
}
return true
}

关于ios - 通用链接、continueUserActivity 和 sourceApplication 未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45369641/

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