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: facebook login show browser and native at the same time #785

Open vongkeo opened 4 years ago

vongkeo commented 4 years ago

Hello there, I have a problem with facebook LoginManager with "web_only" behavior but the result is when i click FB login button it show webview first after that there is a popup alert say "open this page in facebook app" continuously, And when i click on "open" option the native "Login with facebook" screen appear and last when i click on continues with the account in facebook app it go back to facebook login webview page in my application. So we are not getting response from facebook sdk.

Please do reply ASAP Thanks, IMG_5525 IMG_5526 IMG_5527 IMG_5528

GalushkoVasiliy commented 4 years ago

Same issue

Poojapandey89 commented 4 years ago

Having the same issue, please reply ASAP.

prih commented 4 years ago

just follow the documentation, i think the problem with this:

AppDelegate.m

#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [[FBSDKApplicationDelegate sharedInstance]application:app
                                                       openURL:url
                                                       options:options];
}

https://developers.facebook.com/docs/ios/use-cocoapods https://github.com/facebook/react-native-fbsdk/blob/master/example/ios/RNFBSDKExample/AppDelegate.m

Poojapandey89 commented 4 years ago

@prih The AppDelegate.m implementation is same. The issue is with iOS version 13 and above. Is there any new integration to be done for iOS 13 and above?

prih commented 4 years ago

@Poojapandey89 tested this on 13.6.1 everything is ok, after change AppDelegate.m

JeyShah commented 4 years ago

@Poojapandey89 Anyone got solution for this?

Poojapandey89 commented 4 years ago

@JeyShah Updated the AppDelegated.m File with- AppDelegate.m

HerbertLim commented 3 years ago

I think the following code, mentioned by @prih and @Poojapandey89, is missing or not updated in iOS Quick Start documentation.

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

Quick start requests to include the following code, which is different from the above code(Code A):

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

Now Xcode 12.2 shows the method(Code B) in Quick Start is deprecated, as shown below: image

I added Code A to my AppDelegate.m and now facebook login completes normally. Thanks @prih and @Poojapandey89 .

By the way, my method definition was slightly different:

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

I replaced return [RCTLinkingManager application:application openURL:url options:options]; with

  return [[FBSDKApplicationDelegate sharedInstance]application:application
                                                       openURL:url
                                                       options:options];
platoonic commented 3 years ago

Any updates for this issue? I've used @prih and @Poojapandey89 codes and it's still not working, stuck at the webview after logging in on FB app.

aguscha333 commented 3 years ago

@HerbertLim thank you so much for your answer, my case was exactly that. I had the deprecated warning and was implementing the new method but for other linking related stuff so I had to merge what I had with this facebook bit on the new method and it worked like a charm!