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 907 forks source link

[IOS ONLY] logInWithPermissions infinite loop when using Facebook App login #611

Closed gabsbelini closed 5 years ago

gabsbelini commented 5 years ago

🐛 Bug Report

LoginManager.logInWithPermissions enter in a infinite loop state when trying to login using the user's facebook App on IOS. Loop description:

  1. execute logInWIthPermissions
  2. Facebook modal is opened asking to login using the app or using Cellphone/email
  3. click on Log in with the Facebook App
  4. Alert asking "Open with Facebook?" shows up
  5. Click "Open"
  6. You've connected to MyApp previously, do you wish to continue?
  7. Continue
  8. Sends me back to the step 1 and never enters the .then() of logInWithPermissions.

The code written on the section below works fine on Android for both logging in with Facebook app and logging in with email. It also works fine on IOS if you log in using your email and Password instead of the Facebook App itself.

To Reproduce

  1. Install Facebook App into your iPhone
  2. If you're logged in on your facebook account either on a web browser or on the app, Logout from all of those.
  3. Within your development app, execute the following:

    const response = await LoginManager.logInWithPermissions(['public_profile', 'email']).then(
      function (result) {
        if (result.isCancelled) {
          console.log('Login canceled')
        } else {
          return AccessToken.getCurrentAccessToken()
        }
      },
      function (error) {
        console.log('Error when trying to login ' + error)
      }
    )

Expected Behavior

The then part of the Promise should be executed.

Code Example

const response = await LoginManager.logInWithPermissions(['public_profile', 'email']).then(
      function (result) {
        if (result.isCancelled) {
          console.log('Login canceled')
        } else {
          return AccessToken.getCurrentAccessToken()
        }
      },
      function (error) {
        console.log('Error when trying to login ' + error)
      }
    )

Environment

info React Native Environment Info: System: OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver) CPU: (4) x64 Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz Memory: 11.11 GB / 15.58 GB Shell: 4.4.19 - /bin/bash Binaries: Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node Yarn: 1.9.4 - ~/.nvm/versions/node/v8.11.3/bin/yarn npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 19.1.0, 23.0.1, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3 System Images: android-23 | Google APIs Intel x86 Atom npmPackages: react: ^16.8.3 => 16.8.6 react-native: ^0.59.8 => 0.59.9 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 react-native-epos700: 1.0.0 react-native-git-upgrade: 0.2.7

gabsbelini commented 5 years ago

The issue I had was due to a conflict between RNGoogleSignin and fbsdk. Found the answer in this StackOverflow post