How to get the Push id of current user in Firebase Android?

最后都变了- 提交于 2019-12-11 11:54:49

问题


I have generated the push id of the user who have sign up.

String id=databaseUser.push().getKey();

How I can get this id when the user signs in?

Please help me on this.


回答1:


You can store that id in the database as a property of your User object but a more elegant way would be to use the uid and not that random key provided by the push() method. So once you are authenticated, you can get the uid, using the following line of code:

String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();


来源:https://stackoverflow.com/questions/51348025/how-to-get-the-push-id-of-current-user-in-firebase-android

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