如何在 Xamarin 的 firebase 中更新用户显示名称?

Posted

技术标签:

【中文标题】如何在 Xamarin 的 firebase 中更新用户显示名称?【英文标题】:How do I update a users display name in firebase in Xamarin? 【发布时间】:2021-12-07 06:17:15 【问题描述】:

在 Xamarin 中使用 firebase 创建用户后:

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

我想更新他们的显示名称,这样当我登录他们时,我可以从登录方法返回的内容中获取它。 我尝试了以下方法,但它似乎不起作用,这样做的正确方法是什么?

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

【问题讨论】:

【参考方案1】:

用这个修复它:

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

【讨论】:

以上是关于如何在 Xamarin 的 firebase 中更新用户显示名称?的主要内容,如果未能解决你的问题,请参考以下文章

如何从 Xamarin 中的 Firebase 获取价值?

如何将 Firebase 消息传递到 Xamarin.Android 应用程序?

如何在 Xamarin.iOS 中使用 FCM(Firebase 云消息传递)发送 iOS 推送通知

如何使用 Firebase 在 Xamarin 中实现推送通知和使用 C# 后端的 Apple 推送通知

在 Xamarin iOS 中使用 Firebase Crashlytics

Xamarin Forms 2.3.3.175 和 Xamarin.Firebase.Messaging 不可能?