Can someone help me about this issue? The first error was \"value of type \'authdataresult\' has no member \'uid\'\".
Auth.auth()?.signIn(withEmail: email, p
guard let uid = user?.user.uid else {return}
let ref = Database.database().reference(fromURL: "")
let usersReference = ref.child("users").child(uid)
The new Auth.auth().signIn
and Auth.auth().createUser
methods use a datatype of AuthDataResult?
instead of User?
The old callback was user of type: User?
Auth.auth().signIn(withEmail: email, password: password, completion: { (user: User?, error) in
You would access properties directly on the callback user object such as:
if error == nil {
if let user = user {
self.userUid = user.uid
// user.email for the email address in firebase
}
}
The new callback is authDataResult of type: AuthDataResult?
Auth.auth().signIn(withEmail: email, password: password, completion: { (authDataResult: AuthDataResult?, error) in
Now you access properties directly on the callback authDataResult object such as:
if error == nil {
if let authDataResult = authDataResult {
self.userUid = authDataResult.user.uid
// authDataResult.user.email for the email address in firebase
}
}
Basically the user object from the old way is now a property on the authDataResult object and you can get the uid through there:
authDataResult.user.uid
Firebase's info about AuthDataResult
It seems that Google has made some changes to Firebase Auth with the 5.0.0 update. This worked for me:
self.userUid = user.user.uid
I'm not sure what was the point of the change but it still works exactly the same.