19

I'm currently setting up Facebook Authentication for my Reach Native application. After the usual problems with the react-native-fbsdk setup, now the Facebook App Events work and the LoginManager loads up.

My problem: After Authorisation the LoginManager redirects me back to the app, then shows me the Error:

Login Failed

I'm using the very standard LoginManager implementation:

const FBSDK = require('react-native-fbsdk');
const {
  LoginManager,
  AccessToken,
} = FBSDK;


export default class FacebookAuth extends Component {

  facebook(){
    LoginManager.logInWithReadPermissions(['public_profile', 'email']).then(
  function(result) {
    if (result.isCancelled) {
      alert('Login cancelled');
    } else {
      alert('Login success with permissions: '
        +result.grantedPermissions.toString());
    }
  },
  function(error) {
    alert('Login fail with error: ' + error);
  }
);

Do you have any pointers for me?

I already checked:

  • FB app info in Info.Plist
  • iOS Bundle ID in Facebook App
  • Client OAuth Settings
  • FBSDK LoginButton (same error)

I'm running: iOS 10 & react-native 0.38.0.

Thanks!

Jonas
  • 355
  • 1
  • 4
  • 16
  • 1
    I added Keychain Sharing, LoginManager.logOut() before Login but nothing was solving for me. What solved was using Facebook SDK 4.38.0 instead of latest (Facebook SDK 4.39.0) – cassmtnr Dec 19 '18 at 16:05

4 Answers4

65

Error when login with Facebook SDK — React Native

The problem was that Facebook SDK was still keeping the previous session token, and when I was trying to login again I was getting this error, to solve this problem all I had to do was to call the logOut method from the LoginManager.

try to this before LoginManager.logInWithReadPermissions...

LoginManager.logOut();
Yifan
  • 1,185
  • 12
  • 18
4

After couple of hours trying different solutions, I managed to fix it thanks to Cassiano Montanari and zavadpe's comment from here Incorrect installation

I ended up with this configuration:

Pod file:

  pod 'FBSDKCoreKit', '4.38.0'
  pod 'FacebookSDK', '4.38.0'
  pod 'FBSDKShareKit', '4.38.0'
  pod 'FBSDKLoginKit', '4.38.0'

You need to make sure you add libRCTFBSDK.a in Link Binary With Libraries and to remove 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk' from your pod file.

My issue start ocurring after I upgrade FBSDK to 4.39 and I couldn't find any way to specify the SDK version into the pod file if I use pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk'.

I think one option is to use Carthage, but I haven't try it yet.

3

As per Cassiano Montanari's comment, downgrading from 4.39.0 to 4.38.0 is the fix. I was struggling with this all afternoon and the downgrade solved it immediately.

-1

I think, I resolved the issue. I'm still not 100% clear why, but it related to this: How to use Facebook iOS SDK on iOS 10

After enabling keychain access, the authentication works.

Community
  • 1
  • 1
Jonas
  • 355
  • 1
  • 4
  • 16
  • 1
    I added Keychain Sharing, LoginManager.logOut() before Login but nothing was solving for me. What solved was using Facebook SDK 4.38.0 instead of latest (Facebook SDK 4.39.0) – cassmtnr Dec 19 '18 at 16:06