Initialization Error While Logging With Facebook

Please provide the following:

  1. SDK Version: 35
  2. Platforms(Android/iOS/web/all): iOS (non-ejected)

After redirecting back from Facebook (successful authorization) I get the following error from the Expo SDK:

FBSDKGraphRequestConnection cannot be started before Facebook SDK initialized

My login code:

import * as Facebook from 'expo-facebook'

try {
            const fbAccess = await Facebook.logInWithReadPermissionsAsync('xxxxxxxxxxxx', {
              permissions: ['public_profile', 'email']
            });

            if (fbAccess.type === 'success') {
                alert('OK!')
            } else {
                alert('You cancelled login, maybe try phone login?')
            }
          } catch (err) {
            alert(`Facebook Login Error: ${JSON.stringify(err)}, maybe try login by phone?`);
          }

This happens consistently with the Native App login. I have been looking for a while but can’t figure out what I am doing wrong…

I should precise that this error only happens when using the native app to login. Login through the webview works fine.

I’m also experiencing this issue with v35 and the iOS Facebook app. Same code worked with previous Expo versions.

By the way, in SDK version 36 the Facebook module initialization has been changed:

Facebook module initialization

To prevent unintended data collection, the Facebook module no longer auto-initializes when your app starts up. If your app uses Facebook login, you must initialize the Facebook SDK manually, either at runtime or with an app.json setting, before calling logInWithReadPermissionsAsync . See the docs for more information.

I’m not sure exactly how that would impact on your issue, but it seems to me to be related.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.