1

I implemented the library in my project, but when calling facebook, a webview is always opened and not the native facebook app, even though I have it installed. This happens on IOS and Android. The idea would be to open the native app so that the user doesn't have to enter their login and password via the browser, because this flow is a very bad experience. Could someone give me a light? I already took a look at all possible topics on google, but nothing worked. Even putting it like:

LoginManager.setLoginBehavior("native_only")

Which is the prop that the LoginBehavior can receive.

Any response is welcome. Thank you for your attention.

const LoginWithFacebook = async () => {

  setLoadingFacebook(true)

  LoginManager.logOut();

  LoginManager.setLoginBehavior("native_only")

  const data = await LoginManager.logInWithPermissions(["public_profile", "email"]);

  if(data.isCancelled){
     return  setLoadingFacebook(false)
  }

  const responseToken = await AccessToken.getCurrentAccessToken();

  afterLoginComplete(responseToken?.accessToken?.toString());

}
  • After several hours on this guy, I ended up leaving it by webview, since I didn't find any solution. I think it is no longer possible to open the native app for authentication anyway. – Thales Crisostomo Mar 07 '23 at 02:17

1 Answers1

0

Have you added the following code to your AppDelegate.m?

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
  NSString* fbappid = [infoDict objectForKey:@"FacebookAppID"];
  NSString *fbAppId = [RNCConfig envFor:@"FB_APP_ID"];

  [FBAEMReporter configureWithNetworker:nil appID:fbAppId reporter:nil]; // Replace {app-id} with your Facebook App id
  [FBAEMReporter enable];
  [FBAEMReporter handleURL:url];

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

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

  return NO;
}
Jenipha
  • 41
  • 2