【发布时间】:2017-10-19 21:39:09
【问题描述】:
我在我的 iOS 应用中使用深层链接
customAppScheme://openID#ID=12345
这表示打开一个特定的项目页面。
我想用同样的部分作为动态链接。
使用自定义 URL 生成器
长网址:https://<myCode>.app.goo.gl/?ibi=com%2Ecompany%2EmyAPP&ius=customAppScheme%3A%2F%2FopenID%23ID%3D12345&isi=1234567890&imv=1%2E0&ifl=https%3A%2F%2Fgoogle%2Ecom&link=https%3A%2F%2Fgoogle%2Ecom
绝对网址:https://<myCode>.app.goo.gl/?ibi=com.company.myAPP&ius=customAppScheme://openID#ID=12345&isi=1234567890&imv=1.0&ifl=https://google.com&link=https://google.com
短网址:https://<myCode>.app.goo.gl/aHS1Vq5RZYL6kGR02
构建 ID:“com.company.myAPP”
customScheme: "customAppScheme://openID#ID=12345"
如果我使用长 URL,它可以正常工作。 (我在注释中添加链接并单击链接。) 应用程序打开并转到给定的项目页面。
但是当我使用短 URL 时,应用程序会打开,但之后就没有其他内容了。它不会进入项目页面。
PFB 我的应用委托方法。
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
guard let dynamicLinks = DynamicLinks.dynamicLinks() else {
return false
}
let handled = dynamicLinks.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
if let dynamiclinkURL = userActivity.webpageURL, let urlComponents = URLComponents(url: dynamiclinkURL, resolvingAgainstBaseURL: true) {
if let queryItems = urlComponents.queryItems {
queryItems.forEach { queryItem in
if let value = queryItem.value, queryItem.name == "ius" {
handelLink(url: value)
}
}
}
}
}
return handled
}
此方法非常适用于长网址。但是对于短网址,这不起作用。 如果我做错了什么或遗漏了什么,请告诉我。
提前致谢。
【问题讨论】:
-
我面临同样的短链接 DynamicLinks.dynamicLinks().handleUniversalLink 不重新运行链接或错误的问题
-
这个问题解决了吗?面临同样的问题。
标签: ios swift firebase firebase-dynamic-links