I am pretty new to Firebase. I am trying to check if the user is logged in or not, and by referring to the Firebase doc, the recommended way of doing it would be adding a FIRAuthStateDidChangeListenerHandle.
My code is as follows:
handle = FIRAuth.auth()?.addStateDidChangeListener({ (auth, user) in
//here, we add code to see if we are supposed to be loggin or not
print("hello world")
if user != nil{
self.isLogin = true
}else{
self.isLogin = false
}
})
However, after I checked, it seems that FirAuth.auth() is a nil and the entire block is not called at all.
Any one knows what is wrong here?
This looks like an improperly set up Firebase. Did you follow all the steps here? Specifically, did you, in your AppDelegate, call FIRApp.configure()? Without this configuration call your FIRAuth would likely be nil.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With