【问题标题】:How to open the app when user tap on the firebase dynamic link用户点击firebase动态链接时如何打开应用程序
【发布时间】:2022-01-05 11:55:29
【问题描述】:

我有一个动态链接:https://test.app.goo.gl/name,我已将其添加到相关域:test.app.goo.gl。在 URLTypes 部分的信息中,我添加了 URL Scheme:com.project.lad 当我按下动态链接时,我可以看到带有“在应用程序中打开按钮”的窗口,但是当点击此按钮时,打开的是网站而不是应用程序.

【问题讨论】:

    标签: ios swift firebase firebase-dynamic-links


    【解决方案1】:

    您需要按照提供的文档接收将在您的应用中打开的动态链接 - https://firebase.google.com/docs/dynamic-links/ios/receive

    如果您正确遵循文档,请尝试在 SceneDelegate.swift 文件中添加以下代码。它可能会有所帮助。

    func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
     if let incomigURL = userActivity.webpageURL{
                _ = DynamicLinks.dynamicLinks().handleUniversalLink(incomigURL) { (dynamiclink, error) in
                    if let dynamiclink = dynamiclink, let _ = dynamiclink.url {
                        self.handleIncomingDynamicLink(dynamicLink: dynamiclink)
                    } else {
                        print("dynamiclink = nil")
                    }
                }
    }
    
    
    
     func handleIncomingDynamicLink(dynamicLink: DynamicLink){
            print("Your dynamic link parameter is = \(String(describing: dynamicLink.url))")
           
            let link = dynamicLink.url?.absoluteString
           //your code
    }
    

    【讨论】:

    • 我已经完成了本文档中的所有操作,但还没有工作。
    • 在sceneDelegate中添加上面的代码你可能会在这个文件中得到动态链接的响应。
    • 但它是 SwiftUI 的,我没有场景委托
    猜你喜欢
    • 2019-06-16
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    • 2014-12-09
    • 2021-08-07
    • 2012-03-30
    • 1970-01-01
    • 2016-10-03
    相关资源
    最近更新 更多