user523234
user523234

Reputation: 14834

How to update user with displayName

So I use FIRAuth's createUserWithEmail to create new user. I also want to assign the displayName for this user. But this function only accept email and password. What do I go about to insert displayName?

FIRAuth.auth()?.createUserWithEmail(email, password: password, completion: { (user: FIRUser?, error: NSError?) in


})

Edit: So there seemed to be a function called updateProfile. But it does not seem to be available for the iOS platform library. Any idea?

Edit: Found solution here: Need to use profileChangeRequest function

Upvotes: 12

Views: 5023

Answers (2)

DoesData
DoesData

Reputation: 7047

Documentation is here

let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest()
changeRequest?.displayName = displayName
changeRequest?.commitChanges { (error) in
  // ...
}

Upvotes: 18

Dan Levy
Dan Levy

Reputation: 4281

When you want to change the details of a user in Firebase, you want to use FIRAuth.auth().currentUser.profileChangeRequestin order to update any details other than the user's email and password. To update their email or password, you need to use a specific method for each. updateEmail and updatepassword

Upvotes: 9

Related Questions