java - Firebase not updating Current user Display name
问题描述
I"m using Firebase for Signup and login. I can successfully able to create account in Firebase but when user want to change the profile image and username, then I'm able to change profile image but display name remains same irrespective of any name I choose
Here is the code I"m using
UserProfileChangeRequest profleUpdate = new UserProfileChangeRequest.Builder()
.setDisplayName("Newusername")
.setPhotoUri(uri)
.build();
and I have set task.sucessfull listener by using
if (task.isSuccessful()) {
// user info updated successfully
showMessage("Sucessfully changed");
}
and I get Successfully changed response but when I move back to my profile activity, only new updated image is shown but display name remains same.
Here is the firebase version I"m using
implementation 'com.google.firebase:firebase-auth:11.6.2'
Thanks for help in advance.
解决方案
问题是由于 Firebase 的内部缓存造成的。更新成功后可以调用getCurrentUser().reload()
手动刷新数据。
FirebaseAuth.getInstance().getCurrentUser().reload()
根据文档
公共任务重载()
手动刷新当前用户的数据(例如,附加的提供者、显示名称等)。
推荐阅读
- java - 如何在 JPA 中删除?
- r - R:向地图添加图例
- php - cURL POST 请求仅适用于硬编码的 url
- python - HTTPBasicAuthHandler 的问题(在 cURL 中工作)
- firebase - Firebase 项目的 API 密钥转移到 Google Cloud 上的另一个项目
- python - 如何从字符串中找到不重复的单词?
- javascript - 如何显示数组中的随机值?
- internationalization - 如何成功使用 Angular 内置的 i18n?
- python - JAX vmap 行为
- reactjs - React 最佳实践 CRUD