简体   繁体   中英

Firebase iOS Facebook authentication doesn't work if Facebook app is installed

I have Firebase Authentication for Facebook implemented.

If I log into facebook from my safari browser, and then use Facebook login on my firebase iOS app. It authenticates correctly. So the fundamental integration works.

However if I logoff from the browser or never log in to begin with, and try to login using facebook auth from my app. If you have the facebook app installed and logged in, it will attempt to log in using the app. Here it fails to authorize and simply returns you to the login page.

在此处输入图片说明 在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

Is there something special required to allow handing off to facebook auth through facebook app successfully?

Here's what gets logged when the authentication fails.

2020-09-28 21:02:25.486277-0400 Flixxaid[3832:875073] [connection] nw_read_request_report [C17] Receive failed with error "Software caused connection abort" 2020-09-28 21:02:25.504312-0400 Flixxaid[3832:875073] [connection] nw_read_request_report [C18] Receive failed with error "Software caused connection abort" 2020-09-28 21:02:25.571637-0400 Flixxaid[3832:875509] 6.32.0 - [Firebase/Analytics][I-ACS023000] Deep Link Web URL query is empty User cancelled login 2020-09-28 21:02:26.001549-0400 Flixxaid[3832:875074] [tcp] tcp_input [C23.1:3] flags=[R] seq=3148860654, ack=0, win=0 state=CLOSED rcv_nxt=3148860654, snd_una=3733900017 2020-09-28 21:02:26.002891-0400 Flixxaid[3832:875074] [tcp] tcp_input [C23.1:3] flags=[R] seq=3148860654, ack=0, win=0 state=CLOSED rcv_nxt=3148860654, snd_una=3733900017

Ok I found my coding error... Here was my original code from AppDelegate.swift :

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
  guard let link = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) else { return false }
  self.handleIncomingDynamicLink(link)
  let handled = GIDSignIn.sharedInstance().handle(url)
  let fbHandler = ApplicationDelegate.shared.application(app, open: url,
    sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
    annotation: options[UIApplication.OpenURLOptionsKey.annotation]
  )
  // DynamicLinks.performDiagnostics(completion: nil)
  return handled || fbHandler
}

And here is the correct version that supports condition to handle FB, Google and Dynamic Links correctly...

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
  var dlHandler = false
  if let link = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
    self.handleIncomingDynamicLink(link)
    dlHandler = true
  }
  let handled = GIDSignIn.sharedInstance().handle(url)
  let fbHandler = ApplicationDelegate.shared.application(app, open: url,
    sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
    annotation: options[UIApplication.OpenURLOptionsKey.annotation]
  )
  // DynamicLinks.performDiagnostics(completion: nil)
  return handled || fbHandler || dlHandler
}

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