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

157240295: Handle universal link isn't working

Open DracoRubi opened this issue 6 years ago • 13 comments

Step 1: Describe your environment

  • Xcode version: 11.3.1
  • Firebase SDK version: 4.9.0 and 6.21.0
  • Firebase Component: DynamicLinks
  • Component version: 4.9.0 and 6.21.0
  • Installation method: CocoaPods

Step 2: Describe the problem

There's an issue with the handleUniversalLink method. It returns true, but later in the closure the DynamicLink object has nil url.

This issue is happening even below iOS 13, and doesn't fully match the descriptions in the other current open issues. In #4914, apparently the dynamic link doesn't open the app. In #5122, it only mentions the first open after install.

Steps to reproduce:

I can provide a minimal reproducible example by giving access to my private repository where I have the project stored. The Firebase support ticket 00043830 is related to this issue. I also provided the minimal reproducible example there.

In order to reproduce the issue, install the application, then exit it. Then, if you open the dynamic link using Safari:

If you're testing with DynamicLinks 4.9.0, the following would happen:

  • handleUniversalLink returns true
  • handleUniversalLink callback never gets executed

If you're testing with DynamicLinks 6.21.0:

  • handleUniversalLink returns false
  • handleUniversalLink callback never gets executed

Relevant Code:

func application(_ application: UIApplication, continue userActivity: NSUserActivity,
                   restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    let handled = DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
      // [START_EXCLUDE]
        /**
        NOTES:
         Notice that this callback is never called.
         In my original application, I always expect this callback to be executed, and I never do anything if handled value is false. Should I be doing something?
         */
        self.showDeepLinkAlertView(withMessage: "handleUniversalLink callback with \(String(describing: dynamiclink?.url))")
    // [END_EXCLUDE]
    }

    // But handled is FALSE. Why?
    // [START_EXCLUDE silent]
    if !handled {
        // Show the deep link URL from userActivity.
        let message = "Handled returned false. Why? The url is: \n \(String(describing: userActivity.webpageURL))"
        showDeepLinkAlertView(withMessage: message)
    }
    // [END_EXCLUDE]
    return handled
  }

Additional info:

  • Currently I'm working with a workaround that manually processes the url contained in the userActivity, since handleUniversalLink doesn't give me the url.
  • This issue only happens when the app is already installed. If the app isn't installed, and the user uses the dynamic link, goes through the installation and opens the app, it works just fine (because it uses dynamicLink(fromCustomSchemeURL))
  • Also, it only gives issues with Safari (or opening the link in Notes), because opening the dynamic link with Firefox, Chrome or others opens the application from dynamicLink(fromCustomSchemeURL).

DracoRubi avatar Apr 08 '20 14:04 DracoRubi

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 seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Apr 08 '20 14:04 google-oss-bot

  • Firebase/DynamicLinks (6.22.0):
  • Using short links
  • handled is true
  • dynamicLink.url is nil

Inside of handleUniversalLink:

let handled = DynamicLinks.dynamicLinks().handleUniversalLink(url) { (dynamicLink, error) in

}
(lldb) po dynamicLink
▿ Optional<FIRDynamicLink>
  - some : <FIRDynamicLink: 0x282d07c40, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>
(lldb) po error
nil

I noticed this log: 6.22.0 - [Firebase/Analytics][I-ACS023000] Deep Link Web URL query is empty

iMacHumphries avatar Apr 16 '20 04:04 iMacHumphries

Maybe related: https://forums.developer.apple.com/thread/123554

Possible new format for apple-site-app-association in iOS 13: https://developer.apple.com/documentation/safariservices/supporting_associated_domains_in_your_app?language=objc

iMacHumphries avatar Apr 16 '20 05:04 iMacHumphries

Maybe related: https://forums.developer.apple.com/thread/123554

Possible new format for apple-site-app-association in iOS 13: https://developer.apple.com/documentation/safariservices/supporting_associated_domains_in_your_app?language=objc

The issue is happening in versions below iOS 13, so probably not related?

DracoRubi avatar Apr 16 '20 23:04 DracoRubi

I'm facing second described problem in SDK version 6.2.0 and iOS 13.5.1

  • handleUniversalLink returns false
  • handleUniversalLink callback never gets executed

There is any progress or additional info of this issue?

Thank you!

fastcoretux avatar Jul 16 '20 13:07 fastcoretux

I had the same issue. Add the FirebaseDynamicLinksCustomDomains as array in your info.plist and add your base url for the dynamic link that you have configured in the associated domains. Should be working properly after that :)

moesmaiel avatar Oct 26 '20 12:10 moesmaiel

I had the same issue. Add the FirebaseDynamicLinksCustomDomains as array in your info.plist and add your base url for the dynamic link that you have configured in the associated domains. Should be working properly after that :)

I'm facing the same issue and doing this hasn't resolved it. Does anyone have other suggestions for how to solve this?

The custom domain is specified under Associated Domains and in the Info.plist. It's also whitelisted in the firebase console. Replacing the custom domain with a page.link url everything works fine.

yannxaver avatar Dec 04 '20 15:12 yannxaver

Check the Firebase API Key restrictions in Google Console -- mine was restricted to not allow Dynamic Links API calls from back when we first started using firebase for other things. I wish the API call had given a permission error instead of a 'success' response with a null link!

idsky2 avatar Mar 29 '21 22:03 idsky2

@yannxaver were you able to solve your issue?

sergey-sivchenko avatar Jul 13 '21 09:07 sergey-sivchenko

@yannxaver were you able to solve your issue?

Yes, I was able to resolve it but I can't tell you exactly what eliminated the problem because it's been awhile. If you face the same problem then deleting your xCode build folder / deleting the cache could be an option because sometimes xCode fails to incorporate changes into the build. Also change all the settings on the firebase side back and forth - it's possible that something there didn't initialise correctly.

yannxaver avatar Jul 13 '21 12:07 yannxaver

Hi @DracoRubi , @fastcoretux , others

Is this issue reproducible in the latest FDL SDK?

If yes, could you please provide the FDL link used for reproducing the issue?

eldhosembabu avatar Oct 18 '21 22:10 eldhosembabu

Hey @DracoRubi. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Oct 25 '21 01:10 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@DracoRubi if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Nov 01 '21 01:11 google-oss-bot