- Mastering Firebase for Android Development
- Ashok Kumar S
- 117字
- 2021-06-18 18:49:17
Provider-specific user profile details
The FirebaseUser object returns the provider-specific data in the getProviderData method, using which we can access the information of a user:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
for (UserInfo profile : user.getProviderData()) {
// unique id of the provider (ex: facebook.com)
String providerId = profile.getProviderId();
// UID of the provider
String uid = profile.getUid();
// Name, email address, and profile photo Url
String name = profile.getDisplayName();
String email = profile.getEmail();
Uri photoUrl = profile.getPhotoUrl();
};
}
This code snippet explains the details of provider-based information for the logged in user. Using the UserInfo class, we will be able to access all the details of a user.