I am new to Firebase and i am trying to connect Firebase Auth api into my application, I have followed documentation from newer updated documentation from Official site and all things work fine.
I have done successful SignIn and in my dashboard i got all users after they login.
My problem is i am so confuse about various IDs returned from Firebase
Code is as follows :
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);
}
};
as in above code i am only checking if providerId is firebase then i store information, but if i don't do it, it will give me data two times
and i got two userIds if i use this method : profile.getUid(), I just want to know which one is unique? and which i should use?
And someone can proposed a way for what to do after getting successful signin at application side, It would be very helpful..
The user's Firebase UID. This is unique within a project. Dictionary of all the identities that are associated with this user's account.
actually you are on the right way, for unique id you can use user. getUid() this id will always unique for every user as per their register credentials. Token is basically depends on device which will help you into send notification feature.
UUID is autogenerated based on timestamp and some entropy. UUID's can be sorted based on creation time, this helps to maintain indexes in Firebase. UUID is not some hash of for example the email address, or facebook id or other.
The user data for firebase authentication is stored in firebaseLocalStorageDb in IndexedDB .
A user can sign in with multiple providers. Each provider generates its own unique ID for that user. You can access these under the user info for each provider.
On top of that Firebase Authentication also generates its own unique ID for the user. No matter which provider the user signed in with, they'll end up with the same UID for that. You can find this under FirebaseUser.getUid()
.
To identify a user, you'd normally use the value from FirebaseUser.getUid()
, so in your snippet: user.getUid()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With