Firebase-ios-sdk: 157239669: dynamicLink nil upon first app install

Created on 17 Mar 2020  路  33Comments  路  Source: firebase/firebase-ios-sdk

Xcode version: 11.3.1
Firebase SDK version: 6.19
Firebase Component: DynamicLinks

I tried to create dynamicLink at Firebase console to navigate user to download my app at appStore,
and when they launch app for the first time I keep getting DynamicLink object with nil url.
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool{

let handled = DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
    // Redirect user to specific screen according to requirement.
    DynamicLinks.performDiagnostics(completion: nil)
    print("dynamic link :: \(String(describing: dynamiclink))")

    print("Dynamic link : \(String(describing: dynamiclink?.url))")
    if dynamiclink?.url != nil{
        //                self.logFirebaseAnaylyticsEvent(url: dynamiclink!.url!)
        self.logFirebaseAnaylyticsReopenEvent(url: dynamiclink!.url!)
    }


    //            let path = dynamiclink?.url?.path
    //            if path == "/home" {
    //                print("Redirect to home screen")
    //            }else{
    //                print("Redirect to another screen")
    //            }

}

if !handled {

    // Show the deep link URL from userActivity.
    let message = "continueUserActivity webPageURL:\n\(userActivity.webpageURL?.absoluteString ?? "")"
    showDeepLinkAlertView(withMessage: message)

}
if handled == false{
    UserDefaultStore.DeepLinkingURL = ""
}
return handled

}
Optional(

dynamiclinks

Most helpful comment

No opting-out, the issue still happens.

And when the link is handled, the pasteboard isn't altered

All 33 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

Xcode version: 11.3.1
Firebase SDK version: 6.19
Firebase Component: DynamicLinks

I tried to create dynamicLink at Firebase console to navigate user to download my app at appStore,
and when they launch app for the first time I keep getting DynamicLink object with nil url.
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool{

    let handled = DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
        // Redirect user to specific screen according to requirement.
        DynamicLinks.performDiagnostics(completion: nil)
        print("dynamic link :: \(String(describing: dynamiclink))")

        print("Dynamic link : \(String(describing: dynamiclink?.url))")
        if dynamiclink?.url != nil{
            //                self.logFirebaseAnaylyticsEvent(url: dynamiclink!.url!)
            self.logFirebaseAnaylyticsReopenEvent(url: dynamiclink!.url!)
        }


        //            let path = dynamiclink?.url?.path
        //            if path == "/home" {
        //                print("Redirect to home screen")
        //            }else{
        //                print("Redirect to another screen")
        //            }

    }

    if !handled {

        // Show the deep link URL from userActivity.
        let message = "continueUserActivity webPageURL:\n\(userActivity.webpageURL?.absoluteString ?? "")"
        showDeepLinkAlertView(withMessage: message)

    }
    if handled == false{
        UserDefaultStore.DeepLinkingURL = ""
    }
    return handled
}

Optional(

I got exactly this same issue, I've been trying to solve it since yesterday.

The handleUniversalLink method returns true, but in the completion closure the dynamiclink.url property is nil.

It also seems to happen retroactively in older versions of my app, where I'm absolutely sure it was working.

AFAIK there have been no recent changes in the client SDK. @dmandar, are you aware of any backend changes that could be causing pending links to not be matched properly?

No recent changes in the client. Morgan, can you file a bug for Max to take a look at? Thanks.

Will do. In the meantime, @DracoRubi @nunepradeepkumar can you confirm that dynamic links work correctly otherwise? (i.e. when clicking a link with the app already installed, the link is correctly populated)

Filed b/151846783

In my case, the following happens:

If the dynamic link is clicked from a native iOS application, like Safari, Notes or the camera (reading a QR containing the link), it doesn't work.
In this case, this method is invoked in the AppDelegate:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool
And as per your documentation, the link is processed with:
DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL)
userActivity.webpageURL holds the expected value, but calling the handler fails somehow and the result is nil, as indicated above.

However, if I use another application (Firefox, for example), it does work.
In this case, this method is invoked in the AppDelegate:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
And as per your documentation, the link is processed with:
DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
With no issues, it works perfectly.

EDIT: Added more info!

Will do. In the meantime, @DracoRubi @nunepradeepkumar can you confirm that dynamic links work correctly otherwise? (i.e. when clicking a link with the app already installed, the link is correctly populated)

when clicking a link with the app already installed, the link is correctly populated but received dynamic URL is
Optional(

Same issue here.
Clicking on a dynamic link from the Notes app with the app already installed results in the Firebase SDK to send me a FIRDynamicLink containing a nil url.

The app triggering the dynamic link doesn't seem to have an impact for me:

  • from Notes it opens my app with a nil FIRDynamicLink.url
  • from Messenger or duckduckgo it opens a web page with an "open" button redirecting to my app wtih a nil FIRDynamicLink.url

same issue here (

I see this issue with the app installed.
I have a https://...pages.link deep link I tap in Notes, which takes me to my app right away
In there, I call the FIRDynamicLinks API to handle the deep link, and it returns

We've seen this issue before when the end user opts out save my place in the app (the check box) for pasteboard. @amaurydavid @nunepradeepkumar @DracoRubi can you make sure the user testing this feature hasn't opted out on the app preview page?

Also, when the link is handled, can you check the device's pasteboard contents to see if the dynamic link is present?

No opting-out, the issue still happens.

And when the link is handled, the pasteboard isn't altered

To clarify, the checkbox needs to be filled:
image

Can you check that it's filled in?

Where did you get this screenshot from ? I don't remember seeing this page.

Where did you get this screenshot from ? I don't remember seeing this page.

It should open if you use the dynamic link without your app installed, or if you press down the link for a while and then select "Open in Safari".

To clarify, the checkbox needs to be filled:
image

Can you check that it's filled in?

what if we tell the dynamic link to skip this page?

Then the dynamic link will always fall back to a weak match.

Then the dynamic link will always fall back to a weak match.

What if that page isn't shown? For example, if the user already has the app installed, Safari will automatically open the app without showing that page. Will it fall back to a weak match?

@DracoRubi in that case it'll open the app directly through the system universal link behavior and you'll be able to get the URL from the system callbacks. Dynamic Links rely on the preview page to guarantee strong matching, and it does so by copying the URL to clipboard which the SDK then inspects when the app is opened.

So if we check "skip app preview app" in the links settings, we will never be able to get the actual url from FIRDynamicLink ?
Also, could you define "strong match" and "weak match" ?

@dmandar, can you answer these questions?

Will do. In the meantime, @DracoRubi @nunepradeepkumar can you confirm that dynamic links work correctly otherwise? (i.e. when clicking a link with the app already installed, the link is correctly populated)

when clicking a link with the app already installed, the link is correctly populated but received dynamic URL is
Optional(

I'm getting the same issue. Any idea how to resolve this.

did anyone know how to solve this issue?

@DracoRubi in that case it'll open the app directly through the system universal link behavior and you'll be able to get the URL from the system callbacks. Dynamic Links rely on the preview page to guarantee strong matching, and it does so by copying the URL to clipboard which the SDK then inspects when the app is opened.

In that case... Should we add code to manually handle the URL if handleUniversalLink returns false?

I'd love an answer to my previous question, if possible:

@DracoRubi in that case it'll open the app directly through the system universal link behavior and you'll be able to get the URL from the system callbacks. Dynamic Links rely on the preview page to guarantee strong matching, and it does so by copying the URL to clipboard which the SDK then inspects when the app is opened.

In that case... Should we add code to manually handle the URL if handleUniversalLink returns false?

Hi..looks like there are a couple of issues being discussed here. That said, we are not yet able to repro either of those (qualified below) and need some help in narrowing down the issue.

  1. First app install case: This is handled entirely by dynamic links. Using an app preview page (option presented when you create a dynamic link) is highly recommended. This copies the link to the pasteboard and is used by the FDL SDK to resolve.
    a. Are folks using the app preview page also not able to resolve the dynamic link?
    b. If you do not use the app preview page, we will fall back to fingerprinting to resolve the link - this might not be reliable. If you are seeing this issue, please add details on your device / iOS version.
  2. App already installed case: Please refer to #4914

Hi, any update on this issue.

im having the same problem FDL works perfect when app is installed but as soon as you click the link and have to install app first on open it returns nil.

really need this to work as we use this for marketing and affiliate tracking on our apps.

I am currently using
FirebaseDynamicLinks (4.0.8)

First app install case doesnt work, I disabled the preview link. The SDK is always returning weak link. We have two apps, one is using the default link then it works perfectly, another one is using custom URL and that has problem. The iOS version is 13.4.1, and it's not working for all our test devices. iPhone 6S, iPhone 7 Plus, iPhone X, iPhone XS Max. Any update here, from the requirement we dont want to use the preview page, but is that the only solution here? Thanks

FirebaseDynamicLinks (4.0.8) btw @dmandar

More information, for the one project with custom URL, I have tested with the default firebase dynamic link, appname.page.link and it's working. So I think the problem here is, dynamic link with custom url like get.appname.com is not working without preview page, for new install case. Hopefully this information helps!

I have the same issue.
Please check dynamic link with custom url.

Hello there, any update on this issue?

I' am also experiencing the same problem, so I think I may avoid opening a new issue.

As far as the app is in the background, handling the dynamic links perfectly works, the problematic use case is the first app install / opening the app from a killed state. That case gives me a nil dynamic link URL.

I am using Xcode 11.6, Firebase Dynamic Links 4.2.0.

Any help greatly appreciated.

Same issue here.

Was this page helpful?
0 / 5 - 0 ratings