简体   繁体   中英

How do I update a users display name in firebase in Xamarin?

After creating a user in Xamarin using firebase:

await FirebaseAuth.Instance.CreateUserWithEmailAndPasswordAsync(email, password);

I want to update their display name so that when I sign them in I can just get it from what the sign in method returns. I have tried the following but it does not seem to work, What is the right way to do this?

var changeRequest = user.User.ProfileChangeRequest();
changeRequest.DisplayName = username;
await changeRequest.CommitChangesAsync();    
await firebaseUserInfo.UpdateProfileAsync();

fixed it by using this:

firebaseUserInfo = FirebaseAuth.Instance.CurrentUser;
                UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder().SetDisplayName(username).Build();
                await firebaseUserInfo.UpdateProfileAsync(profileUpdates);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM