I am using Firebase Authentication, and have been able to successfully login with facebook and google in the same iOS app in swift.
My issue is that the only place I seem to have access to the FIRUser class is from the AppDelegate.swift file where the auth info returns.
I can print the user email and other profile info into the console from the AppDelegate.swift file but I am not sure how to render this on the corresponding view through the view controller. It seems to be the same issue for both google and facebook. Anyone else know how to solve this?
You can access your current user anywhere you have imported Firebase
this way: FIRAuth.auth()?.currentUser
.
You can also add an auth state listener this way:
FIRAuth.auth()?.addStateDidChangeListener() { auth, user in
if user != nil {
print(user)
} else {
print("Not signed in")
}
}
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