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

Android - logInWithPermissions always return isCancelled: true on some devices #758

Closed Fasosnql closed 4 years ago

Fasosnql commented 4 years ago

🐛 Bug Report

After release app, on some devices method LoginManager.logInWithPermissions returns isCancelled: true despite user was logged in and Facebook shows that user is logged to my app. But I'm not able to take token, because of first step... And when I'm doing AccessToken.getCurrentAccessToken() I'm receiving null.

To Reproduce

Actually it's hard to reproduce, it's not occurring on all devices. One of them is Samsung Galaxy J7 and Android 9 - but in emulator it is working fine. On Physical device it's not working - only on released app, when I connect device to computer and run debug version of app on the phone then it's working fine.

Expected Behavior

I would like to have answer what should I configure or add to code to avoid this issue and be able to log in on every devices.

Code Example

my function which is called on click:
const loginWithFacebook = async () => {
    // Attempt a login using the Facebook login dialog asking for default permissions.
    try {
      const loginData = await LoginManager.logInWithPermissions([
        'public_profile',
      ]);

      if (loginData.isCancelled) {
        alert('Login interrupted');
      } else {
        const accessData = await AccessToken.getCurrentAccessToken();
        setToken(accessData.accessToken.toString());
        navigation.navigate('Home')
      }
    } catch {
      alert('Something went wrong, Try again');
    }
  }

Environment

npmPackages: react-native-fbsdk => 1.1.2 react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: react-native-cli: 2.0.1

Fasosnql commented 4 years ago

Issue can be closed, problem was with traffic to my server via http - not with fb sdk.