简体   繁体   中英

iOS Swift: Firebase Dynamic Links: Short URL not working

I am using deeplink in my iOS app

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

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

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

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

Link: https://google.com

build ID: "com.company.myAPP"

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

If I use the long URL, it works properly. (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. It doesn't go to the item page.

PFB my app delegate method.

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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