Detached App logging in with native Facebook app

Hey all!
So I managed to get Facebook login working partially. By that my stand alone iOS app is able to open up the Native Facebook app for logging in. BUT! What happens is once I confirm my login my native iOS Facebook app goes blank. Shouldn’t it prompt me that I should return to my detached expo app after confirming my login? I’m at a loss here and want to know if anybody has encountered this problem.

 const { type, token } = await Facebook.logInWithReadPermissionsAsync('[some arbitrary code]', {
            behavior: 'system',
            permissions: ['public_profile']
        });
        this.setState({ loading: true });

        if(token) {
            console.log("Permission Token: ", token);
            await AsyncStorage.setItem('fb_token', token);
        }

        if(type == 'cancel') {
            this.setState({ loading: false });
        }

you’ll need to read this over to ensure that everything is set up properly: Get Started - Facebook SDK for iOS - Documentation - Facebook for Developers

unfortunately in detached projects the tradeoff is that you gain more control but we can do less for you automatically

@notbrent maybe need to deprecate behavior “system” as it only works for iOS <11?

From docs:

— Currently this is only supported on iOS (about “behavior” option)

“system” — This will fallback to web behavior on iOS 11+ as Facebook has been removed from iOS’s Settings.

https://docs.expo.io/versions/latest/sdk/facebook.html#registering-your-app-with-facebook

Today I have spent several hours to get it to work, but then I realized that it will only work for a small percentage of our users.

How did you get your FB login to work? Are you still using the behavior web? Or are you able to utilize Facebook’s native login?

I read carefully these articles

https://docs.expo.io/versions/latest/sdk/facebook.html#usage

Then I added “facebookDisplayName”, “facebookAppId”, “facebookScheme” fields to my app.json
Then I added my app Bundle ID in my Facebook App iOS settings, alongside “host.exp.Exponent”.
Then I added this code

const options = {
  permissions: FACEBOOK_PERMISSIONS,
}

if (Expo.Constants.appOwnership === 'standalone') {
  options.behavior = 'system'
}

const response = await Expo.Facebook.logInWithReadPermissionsAsync(
  FACEBOOK__APP_ID,
  options
))

and tested it in my standalone app.

It falls to “web” on my iPhone as I have iOS > 11, but I am pretty sure that everything should work on iOS < 11

Thanks I’ll do that :slight_smile:

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