简体   繁体   English

如果安装了 Facebook 应用,Firebase iOS Facebook 身份验证将不起作用

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

I have Firebase Authentication for Facebook implemented.我为 Facebook 实施了 Firebase 身份验证。

If I log into facebook from my safari browser, and then use Facebook login on my firebase iOS app.如果我从 safari 浏览器登录 Facebook,然后在我的 firebase iOS 应用程序上使用 Facebook 登录。 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.但是,如果我从浏览器注销或从不登录,并尝试使用我的应用程序中的 facebook auth 登录。 If you have the facebook app installed and logged in, it will attempt to log in using the app.如果您安装并登录了 facebook 应用程序,它将尝试使用该应用程序登录。 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?是否有什么特殊要求可以通过 facebook 应用程序成功移交给 facebook auth?

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 2020-09-28 21:02:25.486277-0400 Flixxaid[3832:875073] [connection] nw_read_request_report [C17] 接收失败,错误为“软件导致连接中止”2020-09-28:210x3205024:25035000 :875073] [connection] nw_read_request_report [C18] 接收失败,错误为“软件导致连接中止”2020-09-28 21:02:25.571637-0400 Flixxaid[3832:875509] [3832:875509] -sFirebase/0lytic-Analytic/0lytic. 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] 844803 ack=0, win=0 state=CLOSED rcv_nxt=3148860654, snd_una=3733900017 2020-09-28 21:02:26.002891-0400 Flixxaid[3832:875074] [3832:875074] [flag] ] 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 :好的,我发现我的编码错误......这是我来自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...这是支持条件以正确处理 FB、Google 和动态链接的正确版本...

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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM