无法使用Auth.auth()。signOut()方法从Facebook Auth帐户注销

时间:2020-07-02 01:10:04

标签: ios swift firebase firebase-authentication facebook-authentication

我在LoginViewController中配置了我的Facebook登录按钮,以及其中的委托方法logInlogOut ...

  func loginButtonDidLogOut(_ loginButton: FBLoginButton) {
    let firebaseAuth = Auth.auth()
    do {
      try firebaseAuth.signOut()
    } catch let signOutError as NSError {
      print("Error signing out: %@", signOutError)
    }
    print("Facebook user is signed out")
  }

...但是我实际上需要将signOut按钮放在其他视图控制器(firstViewController)上,因此现在我的firstViewController上有一个导航按钮,可以执行以下操作代码:

  // MARK: - Sign Out Button

  @objc func signOut(){
    let firebaseAuth = Auth.auth()
    do {
      try firebaseAuth.signOut()
                
      GIDSignIn.sharedInstance()?.disconnect()
                
      let navController = UINavigationController(rootViewController: LoginViewController())
      view.window?.backgroundColor = UIColor.white
      view.window?.rootViewController = navController
      view.window?.makeKeyAndVisible()
    } catch let signOutError as NSError {
      print ("Error signing out: %@", signOutError)
    }
  }

但是,即使它带我回到了loginViewController,它仍然没有使我退出Facebook。我仍然可以看到Facebook按钮说“注销”而不是“登录”。我该如何解决?

0 个答案:

没有答案