Facebook login not working [iOS]

SDK Version: 42
expo-facebook version: 11.3.1
Platform: iOS

Hello team! How are you?

I have a productive application with Facebook login and it does not work on IOS devices. I’ve found that it only happens in devices that have the Facebook Application installed, it works on the simulator.

Once the people start the sign-in flow, after they allow the app, it starts prompting again and never comes back.

This is my code:

    await Facebook,initializeAsync({appId, appName});
    const result = await Facebook.logInWithReadPermissionsAsync({
      permissions: ['public_profile', 'email'],
    });
    if (result.type === 'success') {
        const response = await fetch(
            `https://graph.facebook.com/me?fields=id,name,email&access_token=${result.token}`,
        );
        const userData = await response.json();

        loginBackend(userData.id, result.token);
    }

Relevant config:

{
    name: '[APP_NAME]',
    scheme: '[appname]',
    facebookScheme: 'fb[APP_ID]',
    facebookAppId: '[APP_ID]',
    facebookDisplayName: '[APP_NAME]',
    facebookAutoLogAppEventsEnabled: true,
    ios: {
        infoPlist: {
            NSLocationAlwaysUsageDescription:
            'App uses your location to obtain an estimated time of delivery of your purchases',
            NSLocationUsageDescription:
            'App uses your location to obtain your recommended region.',
            NSLocationWhenInUseUsageDescription:
            'App uses your location to obtain your recommended region.',
            // I've found in a thread that i needed to add those fields to info plist
            CFBundleURLTypes: {
            CFBundleURLSchemes: ['fb[APP_ID]', '[appname]'],
            },
            FacebookAppId: '[APP_ID]',
            FacebookDisplayName: '[APP_NAME]',
            LSApplicationQueriesSchemes: [
            'fbapi',
            'fbapi20130214',
            'fbapi20130410',
            'fbapi20130702',
            'fbapi20131010',
            'fbapi20131219',
            'fbapi20140410',
            'fbapi20140116',
            'fbapi20150313',
            'fbapi20150629',
            'fbapi20160328',
            'fbauth',
            'fb-messenger-share-api',
            'fbauth2',
            'fbshareextension',
            ],
        }
    },
    extra: {
        facebook: {
            // facebook data is not accessible sometimes from app config, so had to add it to extra field
            appId: '[APP_ID]',
            appName: '[APP_NAME]',
            scheme: 'fb[APP_ID]',
        },
    }
}

Notes:

  • It works in Android
  • It does not work in IOS if Facebook App is installed
  • Currently, I’m trying to migrate to expo 43 but I’m having issues with dependencies

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