Alex Alex - 1 year ago 586
Swift Question

Firebase create user with email, password, display name and photo url

According to Firebase site, I am using this code to create a new user:

firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {});

How can I add display name and photo url to Auth when creating the new user?

This link shows the supported user data returned from an identity provider in Auth.

Answer Source

You can update your profile with FIRUserProfileChangeRequest class .. check this Doc.

let user = FIRAuth.auth()?.currentUser
   if let user = user {
      let changeRequest = user.profileChangeRequest()

      changeRequest.displayName = "Jane Q. User"
      changeRequest.photoURL =
          NSURL(string: "")
      changeRequest.commitChangesWithCompletion { error in
        if let error = error {
          // An error happened.
        } else {
          // Profile updated.