Facebook login promise rejection on iOS

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 .

hey all, a solution for people who don’t want to or aren’t ready to upgrade to SDK 36 yet. Apparently the new Expo client (v2.14.1) is set up to only work with the new SDK 36 Facebook module approach. To still be able to use Facebook Login on SDK 35 projects, you have to delete the client from your phone / simulator and then use the expo client:install:ios command from the cli. This will prompt you to install the correct version of the client for your project (i.e. v2.13.0 for SDK 35). This allows you to use Facebook Login again on SDK 35. I assume it’s same for earlier versions of Expo as well.

3 Likes

After update from 35 to 36 with expo update, I’m receiving the current error message

React Native version mismatch.

Javascript version: 0.61.4
Native version: 0.59.8

Does someone have receiving this message also?

The same issue here

Haven’t had this error, but it seems its just as the error says, a RN version mismatch. You are using 0.59 while SDK 36 uses 0.61

Just update your RN version and you should be fine.

Hi, sorry for my bad English, but I had this problem and my solution was that I have to initialize Facebook api. I read this on the documentation https://blog.expo.io/expo-sdk-36-is-now-available-b91897b437fe.
This is what I added to my code : Facebook.initializeAsync(FacebookApi.application_id);

Hello I found the solution to this error, the solution is very easy .
1- Delete your folder node_modules of your project

2- In your file app.json
Make sure you had sdk version 36.
"sdkVersion": "36.0.0",

3- In your package.json Make sure you had this update .
"expo": "^36.0.0",
"expo-facebook": "~8.0.0",
"react": "~16.9.0",
"react-devtools": "^3.6.3",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"devDependencies": {
"babel-preset-expo": "~8.0.0",
....
},
Remove "expokit": "^34.0.2" you can install afther .
4- The correct way for initialize the login.

await Facebook.initializeAsync(ConfigApp.facebookAsynConfig.appId);

const { type, token} = await Facebook.logInWithReadPermissionsAsync({
            permissions: ['public_profile', 'email']
          }
        );

5-npm install or yarn install .
npm install work good for me.

Ask any question .

Is this a bug? I am new in expo development. I was under impression, declaring facebook related config in app.json would automatically be placed in Info.plist for iOS. Is it not the case? I am having the same problem when I do not pass in app id explicitly in Facebook.initializeAsync function. I am currently using,

expo-cli: 3.11.5
expo: 36.0.2
expo-facebook: 8.0.0

Hi, I upgraded the expo SDK version to 36.0.0 and invoked the Facebook.intializeAsync(appId) function before calling the logInWithReadPermissionsAsync call but still I am getting this
Error: Facebook SDK has not been initialized yet.
please help, here is my code below

await Facebook.initializeAsync(Constants.manifest.facebookAppId)
const { type, token } = await Facebook.logInWithReadPermissionsAsync({ permissions });

Once after deleted the node modules, ran npm i now works fine. thanks!

Hello, everyone.
I read your valuable messages and those are good help for me.
I am facing this issue on only ios.
It is working well on Android but on ios, I can see this error.

An error occurred Object {
“error”: “Tried to perform Facebook login, but no Facebook app id was provided. Specify Facebook app id in Info.plist.”,
}

Eventhough I added facebook app id on app.json.

"ios": {
     ...
      "infoPlist":{
        "facebookAppId": "XXXXX"
      }
    },

My env:
expo : 35

So I upgraded expo to 36 and add the Facebook.initializeAsync(facebookAppId)

But unfortunately, after upgrading I see this error.

I am confused.

Please let me know which way is best… if there is a good way on sdk 35 or after upgrading to 36, how to this issue solve.

Thanks again.