Firebase: Get DisplayName from UID [duplicate]

天大地大妈咪最大 提交于 2019-12-06 05:41:51
Jaimin Thakkar

You can't

The explanation is here How do I return a list of users if I use the Firebase simple username & password authentication

You can instead set the user's uid to users node in your database, I use that node to store other user's information. then you can get the number of childs under that node.

Dwijraj Bhattacharyya

One solution is when you register a user add his details in database also

Example Once you are under createUserWithEmailandPassword()

DatabaseReference db=FirebaseDatabase.getInstance().getReference();
DatabaseReference users = db.child("Users").child(mAuth.getCurrentUser().getUid());
users.child("Name").setValue("<NAME>"); 

Now when the user signs into your database retrieve the Name from the database from child Users

You can't get the name, or any other details of a user that is not currently signed in using FirebaseAuth.

Instead, you must create a node in your database where you store the name, and any other necessary details by querying the database.

I'm really curious to know how you have the UID of any other user without doing this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!