React-native-fbsdk: iOS : prevent using Facebook app

Created on 17 Feb 2020  路  6Comments  路  Source: facebook/react-native-fbsdk

馃悰 Bug Report

I'm my React Native app, I am trying to prevent user from using the Facebook app (if he has it installed on his device) to login in.
I want the user to use the browser to login via Facebook but it does not work.

To Reproduce

  • Click on a button that will call the Facebook login (see code below)
  • The in app browser does appear but the only option is to login with the Facebook app

S茅lection_017

  • If I do login with the Facebook app, I come back to the in app browser, with no access token

S茅lection_018

S茅lection_017

Expected Behavior

  • I expect to come back to my React Native code and be able to retrieve the access token.

Code Example

// on button click

LoginManager.setLoginBehavior(Platform.OS === 'android' ? 'web_only' : 'browser')

const result = await LoginManager.logInWithPermissions(['public_profile', 'email'])

if (result.isCancelled) {
    throw new Error('Facebook login cancelled')
}

if (result && result.grantedPermissions) {
    console.log(`Login success with permissions: ${result.grantedPermissions.toString()}`)
}

const data = await AccessToken.getCurrentAccessToken()

return data ? data.accessToken.toString() : void 0

Environment

react-native: 0.61.5
react-native-fbsdk: 1.1.1

Most helpful comment

Check your AppDelegate.m file.

This code:

if ([[FBSDKApplicationDelegate sharedInstance] application:application
                                                              openURL:url
                                                    sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                            annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
        ]) {
     return YES;
   }

should be above this code:

  if ([RCTLinkingManager application:application openURL:url options:options]) {
    return YES;
  }

Otherwise, RCTLinkingManager will process the link instead of FBSDK

All 6 comments

+1

+1

Check your AppDelegate.m file.

This code:

if ([[FBSDKApplicationDelegate sharedInstance] application:application
                                                              openURL:url
                                                    sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                            annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
        ]) {
     return YES;
   }

should be above this code:

  if ([RCTLinkingManager application:application openURL:url options:options]) {
    return YES;
  }

Otherwise, RCTLinkingManager will process the link instead of FBSDK

I'm not even able to reproduce this. Even if i install the facebook app, I only get the web version.

IMG_8452

I'm not even able to reproduce this. Even if i install the facebook app, I only get the web version.

If you want to reproduce this issue, then login to your facebook app and close it. Then logout facebook credentials from safari browser. Now open your app and click on login with facebook, you will see the issue

@torcoste

Check your AppDelegate.m file.

This code:

if ([[FBSDKApplicationDelegate sharedInstance] application:application
                                                              openURL:url
                                                    sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                            annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
        ]) {
     return YES;
   }

should be above this code:

  if ([RCTLinkingManager application:application openURL:url options:options]) {
    return YES;
  }

Otherwise, RCTLinkingManager will process the link instead of FBSDK

What should be the version of FBSDK and react-native-fbsdk? This doesn't seems to working for me despite me giving your above code even in the latest version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

santilorenzo picture santilorenzo  路  3Comments

vladotg picture vladotg  路  5Comments

notlose picture notlose  路  5Comments

chirag04 picture chirag04  路  4Comments

stevesaygoodbuycom picture stevesaygoodbuycom  路  5Comments