且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Firebase控制台中的“身份验证"面板获取用户信息

更新时间:2022-06-17 07:04:44

是的,您可以使用多种方法访问这些值.为了获得提供者,我建议您使用以下代码:

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.

希望有帮助.