[英]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.