我正在我的iOS应用中添加Firebase动态链接。我根据文档进行了配置,直到现在为止。 在测试时,我注意到该链接打开了应用程序并调用了方法:
application (_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]
工作!
但是当我再次单击链接(动态链接)时,它只是打开应用程序而没有调用该方法。
有人可以帮我吗?
我的代码:
private func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
let handled = DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
// let vc = NomeStoryboard.instance.configuracoes.instantiateViewController(withIdentifier: "idSB_ConfiguracoesApp_Onboard") as! ConfiguracoesAppPageViewController
// UIApplication.shared.keyWindow?.rootViewController = vc
}
return handled
}
@available(iOS 9.0, *)
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
return application(app, open: url,
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
annotation: "")
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
// Handle the deep link. For example, show the deep-linked content or
// apply a promotional offer to the user's account.
// ...
return true
}
return false
}
}
答案 0 :(得分:0)
didFinishLaunchingWithOptions
返回true。continueUserActivity
版本稍旧-也许尝试使用更现代的签名: func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool