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

Wout Ongena 276 Reputation points
2021-10-20T13:02:30.63+00:00

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();
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,491 Reputation points Microsoft Vendor
    2021-10-21T07:35:21.247+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    You can use following code from SO's thread:https://stackoverflow.com/questions/69645770/how-do-i-update-a-users-display-name-in-firebase-in-xamarin

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

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful