在Firebase中获取用户名,姓氏和ID

问题描述:

我使用firebase创建了一个登录/注册,并且工作正常.但是我需要从用户那里获取姓名和姓氏.我怎样才能做到这一点?我想知道是否有可能从用户那里获得ID,因为我想在我的应用中创建一个排名页面,因此只有ID是唯一的.

I created a login/register using firebase, and it's working fine. But I need to get name and lastname from the user. How can I do this? And I'd like to know if it's possible to get an ID from the user, because I want to create a Rank Page in my app, so only an ID would be unique to do this.

要获取唯一ID,您可以使用:

To get a Unique ID, you can use:

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

要获取他的名字(我从未在Email/password auth中尝试过此操作,但在第三方提供者auth上可以正常使用):

To get his name (I never tried this in Email/password auth, but it works fine on 3rd party providers auth):

String name = user.getDisplayName();