问题描述
因此我注意到在Firebase控制台中,有一个名为身份验证"的面板,其中包含用户列表.每个用户都有四段信息:标识符,提供者,已创建,已登录和用户UID.
So I notice in the Firebase console, there's a panel called "Authentication" that contains a list of users. Every user has four pieces of information: Identifier, Provider, Created, Signed in, and User UID.
我想知道是否有一种方法可以在用户未登录时以编程方式访问此信息.
I'm wondering if there's a way you can programmatically access this information, while the user isn't signed in.
谢谢.
推荐答案
是的,您可以使用多种方法访问这些值.为了获得提供者,我建议您使用以下代码:
Yes you can access those values using several methods. In order to get the provider, i suggert you using this code:
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
if (firebaseUser != null) {
for (UserInfo userInfo : firebaseUser.getProviderData()) {
if (userInfo.getProviderId().equals("facebook.com")) {
Log.d("TAG", "User is signed in with Facebook");
}
if (userInfo.getProviderId().equals("google.com")) {
Log.d("TAG", "User is signed in with Google");
}
}
}
还有其他一些非常有用的方法: getUid()
, getDisplayName()
, getEmail()
, getPhoneNumber()
等.请查看官方文档.
There also other methods which are very useful: getUid()
, getDisplayName()
, getEmail()
, getPhoneNumber()
and so on. please take a look at official documentation.
作为该问题的结论,无法调用另一种方法来获取用户的电子邮件地址.您可以做什么,您可以在 Firebase数据库
中创建一个 users
部分,存储所需的所有数据,而不仅仅是查询.
As a conclusion for this question, there's no way in which you can call another method to get the email address of an user. What can you do in stead, you can create a users
section in your Firebase database
, store all data you need and than just query it.
希望有帮助.
这篇关于从Firebase控制台中的“身份验证"面板获取用户信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!