如何在Firebase Android中获取当前用户的Push ID? [英] How to get the Push id of current user in Firebase Android?
本文介绍了如何在Firebase Android中获取当前用户的Push ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已生成注册用户的推送ID.
I have generated the push id of the user who have sign up.
String id=databaseUser.push().getKey();
用户登录后如何获取此ID?
How I can get this id when the user signs in?
请帮助我.
推荐答案
您可以将该ID作为用户对象的属性存储在数据库中,但更优雅的方法是使用uid
而不是该随机密钥由push()
方法提供.因此,一旦通过身份验证,就可以使用以下代码行获取uid
:
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();
这篇关于如何在Firebase Android中获取当前用户的Push ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文