Facebook login promise rejection on iOS

Please provide the following:

  1. SDK Version: ^33.0.0
  2. Platforms(Android/iOS/web/all): iOS

I integrated Facebook auth into my react-native app two weeks ago. Everything was working fine until today. Today when I tried to login, it thrown an promise rejection error on iOS device but works fine on android.

[Unhandled promise rejection: Error: Tried to perform Facebook login, but no Facebook app id was provided. Specify Facebook app id in Info.plist.]

Here is my login function :

async handleFacebookButton() {
    const { type, token } = await Facebook.logInWithReadPermissionsAsync(
      FACEBOOK_APP_ID,
      {
        permissions: ["public_profile", "email"]
      }
    );
    if (type === "success") {
      this.props.navigation.navigate("Browse");

      //Firebase credential is created with the Facebook access token.
      const credential = firebase.auth.FacebookAuthProvider.credential(token);
      const response = await fetch(
        `https://graph.facebook.com/me?access_token=${token}`
      );
      alert("Hello " + (await response.json()).name);
      auth.signInWithCredential(credential).catch(error => {
        this.setState({ errorMessage: error.message });
      });
    }
  }

FACEBOOK_APP_ID is imported from another file.

2 Likes

I have the same exact issue in the same environment.
The same code properly logs in on Android devices, but always return “Cancel”.

1 Like

Uh oh! . So for you it doesn’t work on android too? am I right? :frowning:

For me it works perfectly on android, on iOS it returns a promise rejection error.

Exactly… It keeps saying I need to provide App ID even when it’s given, and I’ve tried different versions of expo-facebook with no luck.

I did quite some digging and my best guess is that Facebook-ios SDK had some underlying changes that affected this API call :frowning: I’ve been struggling to fix this the past two days and it’s so nice to see I’m not the only one experiencing this!

1 Like

Five minutes ago, I tried from my colleague’s iPhone and to my surprise it worked perfectly. Did you try with another iPhone? I am sure it will work. :slight_smile:

Unfortunately, I dont have a different iPhone to try on, and so the results are the same for me :frowning:

1 Like

Oh wow you are correct, I tried running on my physical phone and it works perfectly… OMG, but why is it not running on simulator? Maybe it’s an iOS version issue.

1 Like

I am glad it worked! . I think so too. What is your iOS version?

Ahh sorry, just kidding, I logged out of my application on my phone and tried to log back in… same issue, the Login API doesnt work :frowning:

Really? I am confused. Were you joking about it earlier or did it work on your phone?

No, I was not joking, the app was functioning properly earlier probably due to previous active session. I then logged out of the app and tried logging back in, then encountered the same error.

Oh, I see. I don’t know what going wrong here. It worked on my colleague’s iPhone and another android phone. Its really annoying.

+1 this same exact error is happening to me as well despite specifying the facebookScheme, facebookAppId, and facebookDisplayName in app.json.

I am also facing this issue on iOS using SDK 33 and I have an educated guess from where this bug might be coming from.

According to Expo SDK 36 release post, the facebook module now has to be initialized with initializeAsync() BEFORE calling logInWithReadPermissionsAsync().

Of course that this should be applicable only to apps using version 36 of expo SDK, but since I am using expo-app on simulator on version 2.13.x and there it works fine, but using expo-app on 2.14.x on real iOS device (which got updated automatically overnight) I am getting the issue, maybe the latest expo-cli (3.11.x) and latest expo-app (2.14.x) both have issues specific to iOS that prevent them from realizing the legacy behaviour on facebook module of previous SDKs, thus producing the error.

Again, just a guess and huge thanks for making expo such a great tool/lib!

Same problem here :frowning:

I think what you said makes sense to me now. It happened overnight :frowning:

I initialized the Facebook module before calling loginWithReadPermissionsAsync() . This is the error I get in my console now.

Facebook.initializeAsync is not a function

I just bumped my Expo SDK version from 33.0.0 to 36.0.0 and guess what, Facebook login works on my iOS phone now. :slight_smile: :slight_smile:

2 Likes

Yeap, it also happened overnight for me (due to my physical phone having automatic app updates set to on) and after finding out about the new SDK release and how it changed the Facebook module, I tried the same (bumping to SDK 36) and it worked as well, hence why I did the guessing here for expo team. The thing is that my app isn’t yet ready for that bump to be in production. We have to adjust for all react lifecycle method deprecations and more… So we could really use a fix for expo-app and expo-cli that restores the legacy behaviour of facebook module, if that is possible.

1 Like

What was your fix? I am having this problem as well. The only thing I updated was the expo-cli. How do I bump up to SDK 36?

Is your current version 33.0.0 ? To update SDK run expo update 36.0.0 .