firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

157239669: dynamicLink nil upon first app install

Open nunepradeepkumar opened this issue 6 years ago • 42 comments

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(<FIRDynamicLink: 0x28205af80, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>)

nunepradeepkumar avatar Mar 17 '20 07:03 nunepradeepkumar

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.

google-oss-bot avatar Mar 17 '20 07:03 google-oss-bot

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(<FIRDynamicLink: 0x28205af80, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>)

nunepradeepkumar avatar Mar 17 '20 07:03 nunepradeepkumar

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.

DracoRubi avatar Mar 18 '20 08:03 DracoRubi

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?

morganchen12 avatar Mar 18 '20 16:03 morganchen12

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

dmandar avatar Mar 18 '20 17:03 dmandar

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)

morganchen12 avatar Mar 18 '20 18:03 morganchen12

Filed b/151846783

morganchen12 avatar Mar 18 '20 19:03 morganchen12

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!

DracoRubi avatar Mar 19 '20 09:03 DracoRubi

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(<FIRDynamicLink: 0x280455740, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>)

nunepradeepkumar avatar Mar 19 '20 09:03 nunepradeepkumar

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

amaurydavid avatar Mar 19 '20 09:03 amaurydavid

same issue here (<FIRDynamicLink: 0x280455740, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>)

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 <FIRDynamicLink: 0x280455740, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>

eternalstorms avatar Mar 19 '20 13:03 eternalstorms

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?

morganchen12 avatar Mar 19 '20 17:03 morganchen12

No opting-out, the issue still happens.

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

DracoRubi avatar Mar 19 '20 19:03 DracoRubi

To clarify, the checkbox needs to be filled: image

Can you check that it's filled in?

morganchen12 avatar Mar 19 '20 20:03 morganchen12

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

amaurydavid avatar Mar 20 '20 08:03 amaurydavid

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".

DracoRubi avatar Mar 20 '20 09:03 DracoRubi

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?

LifeEternal avatar Mar 24 '20 10:03 LifeEternal

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

morganchen12 avatar Mar 24 '20 15:03 morganchen12

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 avatar Mar 25 '20 11:03 DracoRubi

@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.

morganchen12 avatar Mar 25 '20 15:03 morganchen12