Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

LoginManager.logInWithReadPermissions using Facebook App fails to resolve/reject promise on iOS #407

Closed
demoran23 opened this issue Nov 8, 2018 · 18 comments

Comments

@demoran23
Copy link

Environment

Environment:
OS: macOS High Sierra 10.13.6
Node: 10.11.0
Yarn: 1.10.1
npm: Not Found
Watchman: 4.9.0
Xcode: Xcode 10.0 Build version 10A255
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.53.0 => 0.53.0

Description

On iOS, invoking LoginManager.logInWithReadPermissions provides an intermediary screen. Log in with the Facebook App > successfully authenticates, but returns back to the intermediary screen, rather than the source application. Using Log in with phone or email returns back to the source application.

Only upon hitting Cancel does the promise resolve or reject (in this case, it resolves with isCancelled as true).

The promise should resolve once authenticated using the Facebook App, and not bring us back to the choice screen.

Reproducible Demo

LoginManager.logInWithReadPermissions(['public_profile', 'email', 'user_friends', 'user_location'])
.then(console.log).catch(console.warn);

@deejaygeroso
Copy link

deejaygeroso commented Nov 9, 2018

I have the same problem.
The issue only occurs on IOS.
It works perfectly fine on Android.
Yet still cannot find any solution.

@alanleeeh
Copy link

same goes to me, any alternative like disabling the login via facebook application instead? I'll prefer temporary disable the login via application if this issue couldn't be solved quickly

@demoran23 demoran23 changed the title LoginManager.logInWithReadPermissions using Facebook App fails to resolve/reject promise LoginManager.logInWithReadPermissions using Facebook App fails to resolve/reject promise on iOS Nov 9, 2018
@jmelendev
Copy link

jmelendev commented Nov 10, 2018

I'm running into the same issue as above and haven't been able to find a solution. This is occurring on iOS for me as well, i'm running these versions: "react-native": "0.57.1" and "react-native-fbsdk": "^0.8.0"

@lengzuo
Copy link

lengzuo commented Nov 12, 2018

Was trying to debug in the xCode and notice the SDK never callback when the login is successful.

@Martian2Lee
Copy link

Martian2Lee commented Nov 12, 2018

Same issue isCancelled as true if you choose Log in with the Facebook App > , but it works if you manually enter email and password.

@Martian2Lee
Copy link

Found a solution, it works for me.
facebook/react-native#12877 (comment)

@lengzuo
Copy link

lengzuo commented Nov 13, 2018

@Martian2Lee thank for saving my life. Good work bro.

@demoran23
Copy link
Author

Found a solution, it works for me.
facebook/react-native#12877 (comment)

I already have the following. Is Linking required to make this work?

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
  return
  [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}

@jmelendev
Copy link

I was able to do this by doing the following:

*Note this is on iOS only, I haven't tested this on android.

After following the installation and setup instructions here

  1. Download the react-native-fbsdk repo.
  2. Copy the RCTFBSDK.xcodeproj in the ios folder to the libraries folder in your apps expo project.
  3. Make sure you have the FB SDK source files in the~/Documents/FacebookSDK directory. Open xcode and open the RCTFBSDK.xcodeproj. Go to Build Settings and in the Framework Search Paths field add this path $(HOME)/Documents/FacebookSDK by clicking the "+" button.
  4. Open your apps .xcodeproj file in xcode and go to Build Settings and in the Framework Search Paths field add this path $(HOME)/Documents/FacebookSDK by clicking the "+" button.
  5. Be sure that the Build Phases > Link Binary with Libraries looks something like this. (Assuming you are using the same frameworks from the documentation prior to step one.

fbsdkinstall

  1. Open your apps .xcodeproj file in xcode again and build the project.

Worked for me so hope that helps.

@worapolburaphan
Copy link

@jmelendev don't work for me

@deejaygeroso
Copy link

@demoran23 have you find any solutions yet?
@Martian2Lee @jmelendev solutions unfotunately did not work for me

@jmelendev
Copy link

@jmelendev don't work for me

for step 6 try opening the .xcworkspace file instead

@heyman333
Copy link

heyman333 commented Nov 30, 2018

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

func application(_ application: UIApplication, open url: URL,      sourceApplication: String?, annotation: Any) -> Bool {
    return   FBSDKApplicationDelegate.sharedInstance().application(application, open: url as URL!, sourceApplication: sourceApplication, annotation: annotation)
}

func applicationDidBecomeActive(application: UIApplication) {
    FBSDKAppEvents.activateApp()
}

Although above code is wrriten in swift.
you guys can confirm that all necessary code exist in AppDelegate.m file

@deejaygeroso
Copy link

deejaygeroso commented Dec 12, 2018

@heyman333

I only have this on my

AppDelegate.m

`

  • (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

    return [[FBSDKApplicationDelegate sharedInstance] application:application
    openURL:url
    sourceApplication:sourceApplication
    annotation:annotation]

    || [RNGoogleSignin application:application openURL:url sourceApplication:sourceApplication annotation:annotation]

    || [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]

    || [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];

}
`

@mjstelly
Copy link

mjstelly commented Dec 23, 2018

None of these responses work for me. I'm using cocoapods. My pod install looks fine. I have these installed

  pod 'FBSDKCoreKit'
  pod 'FBSDKLoginKit'
  pod 'FBSDKShareKit'

My function looks like this:

  handleFacebookLoginTap = () => {
    console.log('FB Tap');
    LoginManager.logInWithReadPermissions(['public_profile', 'email']).then(
      result => {
        if (!result.isCancelled) {
          AccessToken.getCurrentAccessToken().then(async data => {
            const authenticated = await this.props.authStore.authenticateWithFacebook(
              data.accessToken
            );
            if (authenticated === false) {
              this.handleRolePress('TRAINER');
            }
          });
        }
      },
      error => {
        console.log('Login fail with error: ' + error);
      }
    );
  };

When I press the FB button, all I get is the first log statement, then the error message. I get no errors or any indication what causes the error. I don't think the app is grabbing the profile and email parameters.

@demoran23
Copy link
Author

demoran23 commented Jan 14, 2019

Updating the iOS Facebook SDK from 4.32 to 4.38 appears to have fixed this issue for me. 4.39 exhibited other problems.

I'll leave this issue open for now. If others chime in that this fix works for them, we can close it.

pod config:

pod 'FBSDKLoginKit', '4.38.0'
pod 'FBSDKShareKit', '4.38.0'
pod 'FBSDKCoreKit', '4.38.0'

@mjstelly
Copy link

4.38.0 resolved the issue for me.

@demoran23
Copy link
Author

With no further negative input, I'll go ahead and close this issue. It appears to be a bug that existed in 4.32 that does not exist in 4.38.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants