facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 908 forks source link

iOS : prevent using Facebook app #711

Open rlebosse opened 4 years ago

rlebosse commented 4 years ago

🐛 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

Sélection_017

Sélection_018

Sélection_017

Expected Behavior

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
Saad-Bashar commented 4 years ago

+1

fatihmert commented 4 years ago

+1

torcoste commented 4 years ago

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

mifi commented 4 years ago

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

IMG_8452

creativemind1 commented 4 years ago

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

creativemind1 commented 4 years ago

@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.