首页 > 解决方案 > 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.

标签: javaandroidfirebasefirebase-authentication

解决方案


问题是由于 Firebase 的内部缓存造成的。更新成功后可以调用getCurrentUser().reload()手动刷新数据。

FirebaseAuth.getInstance().getCurrentUser().reload()

根据文档

公共任务重载()

手动刷新当前用户的数据(例如,附加的提供者、显示名称等)。


推荐阅读