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

[iOS] Login with facebook through facebook app does not reopen app #590

Open NewBieBR opened 4 years ago

NewBieBR commented 4 years ago

🐛 Bug Report

When I click on continue with facebook, the facebooksdk popup comes up, I click on connect with facebook app, then I go the app -> continue -> blank screen.

It works when I install in debug mode using xcode but doesnt work on release.

To Reproduce

Expected Behavior

Reopen my app after I accept to continue on facebook app.

Code Example

My AppDelegate.m

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>
#import <React/RCTRootView.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
                                            launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"betonyou"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f
                                                    green:1.0f
                                                     blue:1.0f
                                                    alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  [[FBSDKApplicationDelegate sharedInstance] application:application
                           didFinishLaunchingWithOptions:launchOptions];
  return YES;
}

- (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;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#if DEBUG
  return
      [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"
                                                     fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main"
                                 withExtension:@"jsbundle"];
#endif
}

@end

Environment

info React Native Environment Info: System: OS: macOS 10.14.5 CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 3.24 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.4.0 - ~/.nvm/versions/node/v12.4.0/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v12.4.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 27.0.3, 28.0.2, 28.0.3 System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: 10.2/10E125 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.0 => 0.59.0

FadiAboMsalam commented 4 years ago

Same issue here ! please let me know if anything you find help i searched alot with no luck !

tawsifalam commented 4 years ago

I am also facing the same issue even though I accepted the permission. Screenshot 2019-07-24 at 1 44 53 PM

killar4eto commented 4 years ago

Hello, Yeah I have the same problem, in development all works good but in export have the same problem as described on top. I am running with: "dependencies": { "@react-native-community/async-storage": "^1.6.1", "core-js": "^3.1.4", "moment": "^2.24.0", "native-base": "^2.13.4", "react": "16.8.6", "react-native": "0.60.4", "react-native-action-sheet": "^2.2.0", "react-native-app-intro-slider": "^3.0.0", "react-native-autocomplete-input": "^4.1.0", "react-native-autocomplete-select": "^1.0.0", "react-native-calendar-picker": "^6.0.1", "react-native-calendars": "^1.204.0", "react-native-camera": "^3.0.1", "react-native-elements": "^1.1.0", "react-native-fbsdk": "^1.0.1", "react-native-form-builder": "^1.0.16", "react-native-fs": "^2.14.1", "react-native-gesture-handler": "^1.3.0", "react-native-get-location": "^1.2.0", "react-native-google-places-autocomplete": "^1.3.9", "react-native-google-signin": "^2.0.0", "react-native-image-animation": "^1.0.2", "react-native-image-picker": "^1.0.2", "react-native-indicators": "^0.13.0", "react-native-maps": "^0.25.0", "react-native-modal": "^11.3.1", "react-native-multiple-select": "^0.5.3", "react-native-simple-toast": "^0.1.1", "react-native-vector-icons": "^6.6.0", "react-native-video": "^5.0.0", "react-navigation": "^3.11.1", "rn-sliding-up-panel": "^2.3.1" },

nguyenduy2392 commented 4 years ago

ios: Info.plist `FacebookAutoLogAppEventsEnabled

FacebookAutoLogAppEventsEnabled

`

android: AndroidManifest.xml <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/> <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/>

it work with me https://developers.facebook.com/docs/app-events/getting-started-app-events-android#disable-auto-events

ste00martin commented 4 years ago

I had this same issue and I found the solution (at least for my project) if you reorder the return clauses in AppDelegate.m to this it may work:

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

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

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

  return NO;
}

before I had RCTLinkingManager first then FBSDKApplicationDelegate below it.

var77 commented 4 years ago

Adding this code to AppDelegate.m solves the issue for me

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {

  BOOL handled =  [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options];
  // Add any custom logic here.
  return handled;
}