[英]iOS Swift: Firebase Dynamic Links: Short URL not working
我在 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
链接: https : //google.com
构建 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
}
这种方法非常适合长网址。 但是对于短网址,这不起作用。 如果我做错了什么并错过了什么,请告诉我。
提前致谢。
请确保短链接与长链接的参数相同。 要比较链接,请导航到每个链接的调试页面。 将d=1
参数附加到链接的末尾以获取调试页面的 URL。 对于短链接调试页面是https://<myCode>.app.goo.gl/aHS1Vq5RZYL6kGR02?d=1
,对于长链接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&d=1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.