thebergamo / react-native-fbsdk-next

MIT License
633 stars 165 forks source link

Email not retrieving from facebook login #515

Open kneeraj1996 opened 3 weeks ago

kneeraj1996 commented 3 weeks ago

When i am trying to login using facebook in react-native application facebook id, name coming but email is not coming in both android + ios.
"react-native-fbsdk-next": "^12.1.4",

I am doing facebook login integration but email is not coming

This is my function below. const FbLogin = (resCallback: any) => { LoginManager.logOut(); return LoginManager.logInWithPermissions(['email', 'public_profile']).then( result => { console.log('resusts fething===',result) if ( result.declinedPermissions && result.declinedPermissions.includes('email') ) { resCallback({ message: 'Email is required' }); } if (result.isCancelled) { } else { const infoRequest = new GraphRequest( '/me?fields=email,name', null, resCallback, ); new GraphRequestManager().addRequest(infoRequest).start(); } }, function (error) { console.log('error on fb login', error); }, ); };

in output i should get {"id": "2260240041041096", "name": "Neeraj Kalra", "email": "useemail"}

current scenario {"id": "2260240041041096", "name": "Neeraj Kalra", }

Email not coming please help

Environment

System: OS: macOS 13.5.2 CPU: (8) arm64 Apple M1 Memory: 73.38 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.10.0 - /var/folders/52/3m9t5dw93cndmqj2fswkl4m40000gn/T/yarn--1712906941261-0.18384766298515398/node Yarn: 1.22.10 - /var/folders/52/3m9t5dw93cndmqj2fswkl4m40000gn/T/yarn--1712906941261-0.18384766298515398/yarn npm: 10.2.3 - /usr/local/bin/npm Watchman: 2024.01.22.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.15.2 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: 2022.1 AI-221.6008.13.2211.9619390 Xcode: 14.3/14E222b - /usr/bin/xcodebuild Languages: Java: 11.0.15 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.1 => 0.70.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

utiq commented 2 weeks ago

I'm having the same issue, my app is well configured

image
bleszerd commented 1 week ago

You may notice that in the official Android SDK, there isn't a way to retrieve the user's email, so don't expect to be able to get the email using this library. Alternatively, you can call the Facebook API to fetch the email after token creation (remember to include email in the permissions list of your token).

You would have a final URL similar to this: https://graph.facebook.com/me?access_token=[YOUR_TOKEN_HERE]&fields=id,email