【问题标题】:iOS 14 Firebase Dynamic Links IssueiOS 14 Firebase 动态链接问题
【发布时间】:2021-02-21 21:34:54
【问题描述】:

在使用 SwiftUI 的 iOS 14 上,我目前正在尝试在用户单击链接并安装应用程序,然后打开它并从该链接接收信息的情况下测试动态链接。我遵循了这篇文章 (How can I test Firebase Dynamic Links if my app is not in the App Store?) 中的建议,还在 Firebase iOS 网站上实现了所有 AppDelegate 功能。

但是,当我打开链接、安装应用程序,然后第一次打开应用程序时,什么都没有调用(它只是说“从 Safari 粘贴”)。唯一有效的方法是点击动态链接应用已经安装(它会打开应用并正确调用 url 监听器函数)。

这是生成链接的代码:

let dynamicLink = URL(string: "http://www.mydomainishereIjustremovedit.com/?referrer=\(referrerID)")!
        
        //guard let uid = Auth.auth().currentUser?.uid else { return }
        if let referralLink = DynamicLinkComponents(link: dynamicLink, domainURIPrefix: "https://penciltestapp.page.link") {
            referralLink.iOSParameters = DynamicLinkIOSParameters(bundleID: "com.penciltestapp.penciltestapp")
            //referralLink.iOSParameters?.minimumAppVersion = "1.0"
            referralLink.iOSParameters?.appStoreID = "962194608" // Opens up a random app on the app store. Just click this to open the app store, and then install your app from XCode
            
            referralLink.shorten { (shortURL, warnings, error) in
                if let error = error {
                    print(error.localizedDescription)
                    return
                }
                self.inviteURL = shortURL
            }
        }

【问题讨论】:

  • 您能否在您的应用中添加生成动态链接的代码?听起来您还没有设置后备 URL(即,如果设备上未安装应用程序,您需要指定要打开的内容(通常是指向 App Store 或您网站的链接)。
  • 感谢您的回复,尼克。我已经添加了代码。该链接使应用程序商店正确打开 - 只是当我安装应用程序并打开它时,它显示“从 Safari 粘贴”,但它没有调用 url 侦听器方法。我已经在 AppDelegate 中实现了覆盖方法,这些方法在应用程序已安装时正确调用,但在应用程序获取安装然后第一次打开时不正确
  • "...该链接使应用商店正确打开 - 只是当我安装应用并打开它时..." 如果您的应用不在 App Store 中,如何你下载并安装构建?
  • 我按照 (stackoverflow.com/questions/39605657/…) 中的建议提供了解决方法:单击链接(打开 App Store),然后全新安装应用程序通过 XCode 到你的 iPhone 上。当我这样做时,我的屏幕上会弹出一个“从 Safari 粘贴”警报,但没有调用 AppDelegate url 侦听器函数

标签: ios swift firebase swiftui firebase-dynamic-links


【解决方案1】:

别忘了实现这个,在我的情况下这是缺失的

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
  return application(app, open: url,
                     sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                     annotation: "")
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-07
    • 2020-08-18
    • 2020-02-19
    • 2018-03-29
    • 2023-03-16
    • 1970-01-01
    • 2020-11-29
    相关资源
    最近更新 更多