How can i create a user with info about Display Name, username & Profile pic?
Can I use this code?
if let user = FIRAuth.auth()?.currentUser
let
Firebase provides authentication for users using the FIRAuth Clases/API
However they can't be edited with custom fields like the Firebase Database.
To allow custom fields for user, you need to duplicate users in the Database with the same unique uid
you receive in the auth of the user. Something like this
if let user = FIRAuth.auth()?.currentUser {
let name = user.displayName
let email = user.email
let photoUrl = user.photoURL
let uid = user.uid;
let ref = FIRDatabase.database().reference()
let key = uid
let userDict = [ "name" : name ,
"email" : email,
"photoUrl" : photoUrl]
let childUpdates = ["/users/\(key)": userDict]
ref.updateChildValues(childUpdates, withCompletionBlock: { (error, ref) -> Void in
// now users exist in the database
})
}
We push it at the users
end point in our db and with the uid
key by the following line /users/\(key)
.