Firebase - iOS Swift: FIRAuth.auth().signOut() not signing out current user

后端 未结 6 1288
栀梦
栀梦 2020-12-18 04:24

I\'m building an app using Firebase with an initial SignInViewController that loads a sign in page for users to authenticate with email which triggers the follo

6条回答
  •  既然无缘
    2020-12-18 05:06

    Some answers are using a force unwrap when the firebase signing out method can throw an error. DO NOT DO THIS!

    Instead the call should be done in a do - catch - block as shown below

       do {
            try Auth.auth().signOut()
        } catch let error {
            // handle error here
            print("Error trying to sign out of Firebase: \(error.localizedDescription)")
        }
    

    You can then listen to the state change using Auth.auth().addStateDidChangeListener and handle accordingly.

提交回复
热议问题