facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 909 forks source link

FbSDK is not giving email in some cases. #751

Open ritesh-malav opened 4 years ago

ritesh-malav commented 4 years ago

I am using react native Fb-SDK in my project and it works in some of the devices as expected but in some devices I am not getting user email address though the user has set emails address and has not declined any of the permissions.

Here is how I am using sdk:

<LoginButton permissions={['public_profile', 'email']} onLoginFinished={(error, result) => this.facebookSignIn(error, result)} />
    facebookSignIn(error, result) {
        AccessToken.getCurrentAccessToken().then((token) => {
            new GraphRequestManager().addRequest(
                new GraphRequest('/me', {
                    accessToken: token.accessToken,
                    parameters: {
                        fields: {
                            string: 'email,name'
                        }
                    }
                }, (err, res) => {
                    if (err) {
                        console.log("Facebook graph error " + err);
                    } else {
                        this.userCheckAndUpload(res.email);
                    }
                })
            ).start();
        }).catch((err) => {
            console.log("Facebook current access token error " + err);
        });
    }

For some users I am able to fetch their email id but for some users I am just getting id and name. Something is definitely wrong in my code maybe. Can someone help me.

tafelnl commented 4 years ago

I assume to that you are referring to your production code, where sometimes you do not get all information of a specific user.

It could be that this has nothing to do with your code. People have the ability to uncheck any permissions you ask for.

Example: image

Notice the Edit this button. When one clicks on that, one can uncheck email for example. Hence you do not get the email of some (privacy aware/savvy) users.