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

后端 未结 6 1297
栀梦
栀梦 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:28

    You can add a listener in your viewDidAppear method of your view controller like so:

    FIRAuth.auth()?.addStateDidChangeListener { auth, user in
        if let user = user {
            print("User is signed in.")
        } else {
            print("User is signed out.")
        }
    }
    

    This allows you to execute code when the user's authentication state has changed. It allows you to listen for the event since the signOut method from Firebase does not have a completion handler.

提交回复
热议问题