【发布时间】:2017-01-02 16:26:09
【问题描述】:
我是 Firebase 的新手,我正在尝试将 Firebase Auth api 连接到我的应用程序中,我遵循了来自 Official site 的更新文档中的文档,并且一切正常。
我已经成功登录,并且在我的仪表板中我得到了所有登录后的用户。
我的问题是我对从 Firebase 返回的各种 ID 感到非常困惑
代码如下:
for (UserInfo profile : user.getProviderData()) {
// Id of the provider (ex: google.com)
String providerId = profile.getProviderId();
//if Id of the provider is firebase it means we have successfully get back data after saving in firebbase hence we continue to app
if(providerId.equals("firebase")) {
// UID specific to the provider
Other.SavePref(this, "LoginToken", profile.getUid());
// Name, email address, and profile photo Url
String name = profile.getDisplayName();
String email = profile.getEmail();
Uri photoUrl = profile.getPhotoUrl();
Log.e("userinfo", " :: " + profile.getUid()+ " :: " + name + " :: " + email + " :: " + photoUrl);
}
};
在上面的代码中,我只检查 providerId 是否为 firebase,然后我存储信息,但如果我不这样做,它会给我两次数据
- 来自 Firebase
- 也来自 Google
如果我使用这种方法,我会得到两个 userId:profile.getUid(),我只想知道 哪个是唯一的? 和 我是哪个应该用吗?
并且有人可以提出一种在应用程序端成功登录后要做什么的方法,这将非常有帮助..
【问题讨论】:
-
对不起,当你说“如果我使用此方法,我有两个 userId:profile.getUid()”时,我没有得到,用于一次调用方法或对同一方法进行不同调用?
-
假设我使用方法 profile.getUid() 而不检查提供者是 firebase 的条件,那么它将返回 firebase 和 google @MKJParekh 的 id
标签: android firebase firebase-authentication