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

时间:2017-10-19 21:39:09

标签: ios swift firebase firebase-dynamic-links

我在iOS应用中使用了deeplink

customAppScheme:// OPENID#ID = 12345

这表示打开特定的项目页面。

我想在动态链接中使用相同的内容。

使用自定义网址生成器

长网址: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:&#34; com.company.myAPP&#34;

customScheme:&#34; customAppScheme:// openID#ID = 12345&#34;

如果我使用长URL,它可以正常工作。 (我在备注中添加链接并单击链接。) 该应用程序打开并转到给定的项目页面。

但是当我使用短网址时,应用会打开,但之后别无其他。它没有进入项目页面。

PFB我的app委托方法。

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
}

此方法适用于长网址。但是对于简短的网址,这不起作用。 如果我做错了什么并错过了什么,请告诉我。

提前致谢。

1 个答案:

答案 0 :(得分:1)

请确保短链接与长链接具有相同的参数。 要比较链接,请导航到每个链接的调试页面。将char names[SIZE][LENGTH]; while(fgets(names, LENGTH, stdin) != '\0') 参数附加到链接的末尾以获取调试页面的URL。对于短链接,调试页面为d=1,用于长链接https://<myCode>.app.goo.gl/aHS1Vq5RZYL6kGR02?d=1

相关问题