简体   繁体   English

iOS Swift:Firebase 动态链接:短网址不起作用

[英]iOS Swift: Firebase Dynamic Links: Short URL not working

I am using deeplink in my iOS app我在 iOS 应用中使用深层链接

customAppScheme://openID#ID=12345 customAppScheme://openID#ID=12345

This says to open a particular item page.这表示打开特定的项目页面。

I want to use the same as part of the dynamic link.我想使用与动态链接相同的部分。

With the custom URL generator使用自定义 URL 生成器

Long 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%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

Absolute URL: 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/?ibi=com.company.myAPP&ius=customAppScheme://openID#ID=12345&isi=1234567890&imv=1.0&ifl=https://google.com&link=https://google.com

Short URL: https://<myCode>.app.goo.gl/aHS1Vq5RZYL6kGR02短网址: https://<myCode>.app.goo.gl/aHS1Vq5RZYL6kGR02

Link: https://google.com链接: https : //google.com

build ID: "com.company.myAPP"构建 ID:“com.company.myAPP”

customScheme: "customAppScheme://openID#ID=12345" customScheme: "customAppScheme://openID#ID=12345"

If I use the long URL, it works properly.如果我使用长 URL,它可以正常工作。 (I add the link in notes and click the link.) The app opens and goes to the given item page. (我在笔记中添加链接并单击链接。)应用程序打开并转到给定的项目页面。

But when I use the short URL, the app opens but after that nothing else.但是当我使用短 URL 时,应用程序会打开,但之后就没有别的了。 It doesn't go to the item page.它不会转到项目页面。

PFB my app delegate method. 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
}

This method works perfectly for the long url.这种方法非常适合长网址。 But for short url this does not work.但是对于短网址,这不起作用。 Please let me know if I am doing anything wrong and missed something.如果我做错了什么并错过了什么,请告诉我。

Thanks in advance.提前致谢。

Please ensure that short link has the same parameters as long link.请确保短链接与长链接的参数相同。 To compare links, navigate to debug page for each link.要比较链接,请导航到每个链接的调试页面。 Append d=1 parameter to the end of the link to get URL for debug page.d=1参数附加到链接的末尾以获取调试页面的 URL。 For short link debug page is https://<myCode>.app.goo.gl/aHS1Vq5RZYL6kGR02?d=1 , for long link 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对于短链接调试页面是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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM