React-native-fbsdk: [IOS] Error: Login Failed

Created on 21 Jan 2019  路  13Comments  路  Source: facebook/react-native-fbsdk

Environment

Environment:
  OS: macOS High Sierra 10.13.6
  Node: 8.11.2
  Yarn: 1.9.4
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 10.1 Build version 10B61
  Android Studio: 3.2 AI-181.5540.7.32.5056338

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.4 => 0.55.4
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-elements": "^0.19.1",
    "react-native-fbsdk": "^0.8.0",
    "react-native-firebase": "~4.3.8",

Description

I am reopening an issue about this as I am still having troubles with this.

I found this issue that is very alike and tried the different solution there.
https://github.com/facebook/react-native-fbsdk/issues/291

Even doing so I still have a strange behavior with the lib as I can open the facebook login webview, login, but sometimes it works and sometimes I just get the following error : "Error: Login Failed"

Error: Login Failed
    at createErrorFromErrorData (NativeModules.js:121)
    at NativeModules.js:78
    at MessageQueue.__invokeCallback (MessageQueue.js:398)
    at MessageQueue.js:137
    at MessageQueue.__guardSafe (MessageQueue.js:314)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:136)
    at debuggerWorker.js:70

Reproducible Demo

I am using the default signIn and I added LoginManager.logOut(); just in case but with or without this line in both case I have the same issue, sometimes it works at first time and sometimes I just need to try to connect 2 or 3 times to get it working.

  static async signInWithFacebook() {
    try {
      LoginManager.logOut();
      const result = await LoginManager.logInWithReadPermissions(['public_profile', 'email']);

      if (result.isCancelled) {
        throw Error('User cancelled request'); // Handle this however fits the flow of your app
      }

      console.log(`Login success with permissions: ${result.grantedPermissions.toString()}`);

      // get the access token
      const data = await AccessToken.getCurrentAccessToken();

      if (!data) {
        throw Error('Something went wrong obtaining the users access token'); // Handle this however fits the flow of your app
      }

      // create a new firebase credential with the token
      const credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);

      // login with credential
      const currentUser = await firebase.auth().signInAndRetrieveDataWithCredential(credential);
      console.info(JSON.stringify(currentUser.user.toJSON()));

      FirebaseUtils.logEvent('Facebook Connect');

      return currentUser;
    } catch (e) {
      console.log('signInWithFacebook catch', e);
      throw e;
    }
  }

I activated the Keychain just in case too

This issue seems not to affect Android.
Thanks a lot

Most helpful comment

Updating to SDK 4.40.0 solved this issue for me.

All 13 comments

same issue on my side too.

I am also getting same error from last few days.
"react-native": "^0.54.4"
"react-native-fbsdk": "^0.8.0"

While testing I found that, when I try to login with new user I am able to login successful. After logout when I tried to login again with same user, I got error as

Error: Login Failed
at createErrorFromErrorData (NativeModules.js:121)
at NativeModules.js:78
at MessageQueue.__invokeCallback (MessageQueue.js:398)
at MessageQueue.js:137
at MessageQueue.__guardSafe (MessageQueue.js:314)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:136)
at debuggerWorker.js:70

I have the same problem.
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.4",
"react-native-fbsdk": "^0.8.0",
The first time when i try to login with facebook it is successful, but after I logout and then try to login again, I got the error Login Failed. I need to retry multiple times to login(2,3,4 times) to get it working.

Same problem here. I've noticed this happens with the latest 4.39.0 SDK as well as 4.38.0 SDK.

We are also facing same issue.

Facebook release a new version of SDK 4.40.0.
https://developers.facebook.com/docs/android/change-log-4x/

But when I tried pod install, then I got following error:
_[!] CocoaPods could not find compatible versions for pod "FBSDKLoginKit":
In Podfile:
FBSDKLoginKit (= 4.40.0)

None of your spec sources contain a spec satisfying the dependency: FBSDKLoginKit (= 4.40.0).

You have either:

  • out-of-date source repos which you can update with pod repo update or with pod install --repo-update.
  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, pod repo update does not happen on pod install by default._

I don't want to update all pods, so I tried: pod update FacebookSDK, but after all processing Facebook pod is still old: 4.38.0.

Can any one help or suggest?

Updating to SDK 4.40.0 solved this issue for me.

@jnrepo Can you please provide little more information, about how you update your project's pod file? as I am getting CocoaPods could not find compatible versions for pod..... error.

@RajeshKumDev

Run pod repo update then do a pod install. I would also use a Podfile.lock file to maintain version control over the dependencies as well.

@jnrepo did you also update the android version to 4.40.0 ? Still working ?
@RajeshKumDev for me updating to latest version seems to work too for the moment (I am still in testing)

@ishigamii Updated android version to 4.40.0 and started getting proguard errors. Still trying to debug them.

I have the same problem with all updated libs.

I have the same problem with all updated libs.

I have the same problem.

Was this page helpful?
0 / 5 - 0 ratings