I have a strange error when I work in firebase flutter facebook login.
It always results in null email. And when I see the firebase console, the email field is registering with _.
I have searched on StackOverflow to figure out this error but could not succeed.
And I have followed the steps in facebook account for iOS setup.
What kind of possible reasons are there?
And If I try to log in with facebook, this shows "You previously logged in to this app with facebook account" even though I never logged in before... Help me guys. I am struggling with this issue for more than 10 days!!!
// Sign in with Facebook.
static Future<Map<String, dynamic>> signInWithFacebook({bool isSignUp}) async {
try {
await signOutFacebook();
UserCredential userCredential;
// Trigger the sign-in flow
List<String> permissions = ['email', 'public_profile'];
final LoginResult loginResult = await FacebookAuth.instance.login(permissions: permissions);
// Create a credential from the access token
final OAuthCredential facebookAuthCredential =
FacebookAuthProvider.credential(loginResult.accessToken.token);
// Once signed in, return the UserCredential
userCredential = await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
final User user = userCredential.user;
print("User info after facebook login ${user.providerData[0].email} ${user.uid}");
// ************************************** This is showing null email ***** //
if (isSignUp) {
Map<String, dynamic> resultOfSaveSocialUserToDatabase = await saveSocialUserToDatabase(user, 'facebook');
return resultOfSaveSocialUserToDatabase;
} else {
Map<String, dynamic> resultOfValidateSocialLogin = await validateSocialLogin(user, 'facebook');
return resultOfValidateSocialLogin;
}
} catch (e) {
print(e);
return {'success': false, 'message': "Sign up with social account failed"};
}
}



