iOS 14 Firebase动态链接问题

时间:2020-11-09 23:11:07

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

在使用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
            }
        }

1 个答案:

答案 0 :(得分:0)

不要忘记实现这一点,这在我的情况下是缺失的

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: "")
}