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 906 forks source link

iOS 13.5 - Facebook App login routing to App but doesn't do anything. It used to work earlier with other OS verison. #775

Closed joypatel04 closed 4 years ago

joypatel04 commented 4 years ago

🐛 Bug Report

Try to Login with Facebook App and It redirects on successful permission acceptance but doesn't do anything.

To Reproduce

  1. iOS Device should be on version 13.5
  2. Login to app using Facebook app
  3. Allow permission and hit continue at the end
  4. Facebook app will be redirected to our app
  5. Nothing happens

Expected Behavior

It should return a response with success so next, we can grab token using AccessToken.getCurrentAccessToken()

Code Example

const res = await LoginManager.logInWithPermissions([
        'public_profile',
        'email',
        'user_photos',
        'user_gender',
        'user_hometown',
        'user_birthday',
      ]);

Seems like not working with iOS 13.5

https://github.com/facebook/react-native-fbsdk#32-ios

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
    return YES;
  }

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

  return NO;
}

Official docs didn't mentioned about objective-c code:

5. Connect Your App Delegate

https://developers.facebook.com/docs/facebook-login/ios

Environment

System: OS: macOS 10.15.5 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Memory: 106.21 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 14.3.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 Android SDK: API Levels: 26, 28, 29 Build Tools: 28.0.3, 29.0.2 System Images: android-28 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-R | Google APIs Intel x86 Atom, android-R | Google Play Intel x86 Atom_64 IDEs: Android Studio: 3.5 AI-191.8026.42.35.6010548 Xcode: 11.5/11E608c - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.1 => 0.61.1 npmGlobalPackages: react-native-cli: 2.0.1

joypatel04 commented 4 years ago

I had some code in my AppDelegate and due to it, It was not working

Not working code:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    if ([RNBranch application:app openURL:url options:options])  {
        // do other deep link routing for the Facebook SDK, Pinterest SDK, etc
        if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
           return YES;
        }

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

Working code:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
        return YES;
    } 
    if ([RNBranch application:app openURL:url options:options])  {
        // do other deep link routing for the Facebook SDK, Pinterest SDK, etc
        if ([RCTLinkingManager application:app openURL:url options:options]){
           return YES;
        }
    }
    return YES;
}