Issue
in firebase_version = '11.8.0'
there was a method called mAuth.getCurrentUser().getProviders()
i could call to get the list of provider names. so for email provider it was "password" and for facebook is was "facebook.com", etc
the method call was like this:
final FirebaseUser currentUser = mAuth.getCurrentUser()
for (String provider : this.currentUser.getProviders()) {
//i was looping over all the providers this way, and then storing the provider string in my db
}
but now in the latest firebase_version = '12.0.0'
the method getProviders()
is not available.
How can i get the provider names as string ?
Solution
Use FirebaseUser.getProviderData(). It returns a list of UserInfo, each contains a string Provider ID.
For example:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
List<? extends UserInfo> infos = user.getProviderData();
for (UserInfo ui : infos) {
if (ui.getProviderId().equals(GoogleAuthProvider.PROVIDER_ID)) {
return true;
}
}
Answered By - Bob Snyder
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.