Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase dynamic link doesnt work in safari swift

I am using firebase dynamic link. I am facing 2 issues firebase official website doesn't have enough information and already did googling.

(1) When i created link programatically it doesn't work on safari. but if i copy link and open it in chrome or other browser its working like charm.(also doesn't working on facebook app)

(2) I got dynamic link and its working in chrome browser without giving any kind of error. but at firebase console there are no listing for that all links except if i created dynamic link by using console then it will appear in console.(programmatically doesn't reflect on console)

Here is my code for create dynamic link:

let strLink = "https://google.com/page?Id="+self.textField1.text!

    guard let deepLink = URL(string: strLink) else { return }

    let components = DynamicLinkComponents(link: deepLink, domain: "e59pd.app.goo.gl")

    let iOSParams = DynamicLinkIOSParameters(bundleID: "com.procorner.eduflex")
    iOSParams.minimumAppVersion = "8.0"
    components.iOSParameters = iOSParams

    let socialParams = DynamicLinkSocialMetaTagParameters()
    socialParams.title = "Title is here..."
    socialParams.descriptionText = "Description is here"
    socialParams.imageURL = URL(string:"https://firebasestorage.googleapis.com/v0/b/todo-list-1da4a.appspot.com/o/shopping%403x.png?alt=media&token=b5f02235-5c1e-4354-94c5-1354eb36bed9")
    components.socialMetaTagParameters = socialParams

    // Build the dynamic link
    let link = components.url
     print("\n\n\n\nlink",link)
    // Or create a shortened dynamic link
    components.shorten { (shortURL, warnings, error) in
        if let error = error {
            print(error.localizedDescription)
            return
        }
        print("\n\n\nshortURL",shortURL)

        self.strGLink = (shortURL?.path)!
        self.textVIew1.text = shortURL?.absoluteString
        // TODO: Handle shortURL.
    }
like image 986
Mr.Javed Multani Avatar asked Nov 21 '17 13:11

Mr.Javed Multani


People also ask

Do Firebase dynamic links work on iOS?

With Firebase Dynamic Links, you can direct users to either an IOS or Android app from a page, email, or text. If they don't have the app installed, these links can drive users to the appropriate mobile store listing.

How does Swift handle dynamic links?

Open Dynamic Links in your app [FIRApp configure]; If you're using SwiftUI, you must create an application delegate and attach it to your App struct via UIApplicationDelegateAdaptor or NSApplicationDelegateAdaptor . You must also disable app delegate swizzling. For more information, see the SwiftUI instructions.

How does Firebase dynamic links work?

Dynamic Links are smart URLs that allow you to send existing and potential users to any location within your iOS or Android app. They survive the app install process, so even new users see the content they're looking for when they open the app for the first time. Dynamic Links are no-cost forever, for any scale.

How do I create a dynamic link in Firebase?

You create a Dynamic Link either by using the Firebase console, using a REST API, iOS or Android Builder API, or by forming a URL by adding Dynamic Link parameters to a domain specific to your app. These parameters specify the links you want to open, depending on the user's platform and whether your app is installed.


2 Answers

Short answer: Chrome uses URI schemes, Safari defaults to Universal links. This means you can type the firebase link into Chrome and it will open the app via a URI scheme, but in safari you must click on the firebase link to open the app because safari uses universal links.

Explanation

Firebase dynamic links rely on the use of URI schemes OR Universal links to open the app. Safari defaults to using Universal links, whereas Chrome will use the URI scheme if the app is installed. This is important because Universal links will only open an app if they are clicked on, not if they are typed into the address bar or opened programatically. To open the app from Safari, you will need to paste it somewhere that will register it as a link and then click on it.

I suggest using messages or notes to open your firebase links, as this will allow you to click on the firebase links to enable the universal link.

like image 184
clayjones94 Avatar answered Sep 18 '22 23:09

clayjones94


(1) Please clarify how do you test links in Safari? What other browsers besides Chrome works correctly? Also how you test in Facebook iOS App?

If you paste link to browser address bar and hit returns, this will not work. Reason that Firebase Dynamic Links are using Universal Links. Universal Links will not engage when link is pasted to Safari. Firebase Dynamic Links will still handle this case correctly because of AppPreview page. If you pasted link to Safari, you should see AppPreview page. Tapping on OPEN button here should engage Universal Links and open your App.

Chrome deviates from a way how iOS (and Safari) handles Universal Links. Some people would say deviates to the better.

(2) Firebase Dynamic Links created using API will not show up in console.

Reasoning for this: some of our clients like Google Photos creating north of couple millions Firebase Dynamic Links per day. Trying to show this amount of information in console does not looks like good idea. Trying to consume this information in console probably will be not fun.

At the same time, if you have use case that requires you to see all your links in Firebase console, feel free to open Firebase ticket or post details here. We always open for ideas for new features or improvements.

like image 45
Oleksiy Ivanov Avatar answered Sep 20 '22 23:09

Oleksiy Ivanov