简体   繁体   中英

iOS 14 Firebase Dynamic Links Issue

On iOS 14 using SwiftUI, I'm currently trying to test Dynamic Links in the situation where the user clicks the link and installs the app, then opens it up and receives information from that link. I followed the recommendations in this post ( How can I test Firebase Dynamic Links if my app is not in the App Store? ) and also implemented all the AppDelegate functions on the Firebase iOS website.

However, nothing gets called when I open the link, install the app, and then open the app for the first time (It just says "Pasted from Safari"). The only thing that works is clicking Dynamic links when the app is already installed (it opens up the app and calls the url listener functions correctly).

This is the code for generating the link:

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

Dont' forget to implement also this, this was missing in my case

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

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