Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook Login UI Issue #2450

Open
4 of 5 tasks
sufian1999 opened this issue Jun 26, 2024 · 5 comments
Open
4 of 5 tasks

Facebook Login UI Issue #2450

sufian1999 opened this issue Jun 26, 2024 · 5 comments

Comments

@sufian1999
Copy link

sufian1999 commented Jun 26, 2024

Checklist before submitting a bug report

Xcode version

15.0

Facebook iOS SDK version

14.0.0

Dependency Manager

CocoaPods

SDK Framework

Login

Goals

The Facebook login process must be UI issue-free. Buttons shouldn't disappear or go below the screen.
Or is there any way to get the older UI of FBSDKLoginKit?

Expected results

The Facebook login process must be UI issue-free. Buttons shouldn't disappear or go below the screen.

IMG_0707

IMG_0708

Actual results

UI issues occur when the SDK opens the Facebook App for login. When I delete the FB app, then the LoginManager of FBSDK asks the user to login in the web view, and in the web view, the UI is ok.

UI issues like buttons disappearing, and can't scroll.

Image1

Screenshot 2024-06-20 at 11 44 55 AM

Below I gave the code of Objective-C and I bridge it and use it in my react native project.
A fellow developer also tested this on FBSDK versions 17.0.0 and 16.2.1 but got the same issue.

Steps to reproduce

Do FB integration and the Facebook app must be installed.
SDK opens the Facebook app and UI issues come.
Mostly, these issues come on the latest iPhone devices like 15 pro, 15 pro max, 14 pro, and 14 pro max.
On my iPhone 8, this issue doesn't occur.

Code samples & details

// AppDelegate.mm

#import "AppDelegate.h"
#import "FileDownloadModule.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>

#import <FBSDKCoreKit/FBSDKCoreKit.h>

#import <React/RCTAppSetupUtils.h>
#import "RNSplashScreen.h"
#import "Orientation.h"

#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>

#import <react/config/ReactNativeConfig.h>

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
  RCTTurboModuleManager *_turboModuleManager;
  RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
  std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
  facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
  
  //Initialize FB SDK
  [[FBSDKApplicationDelegate sharedInstance] application:application
                      didFinishLaunchingWithOptions:launchOptions];
  
  RCTAppSetupPrepareApp(application);

RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

#if RCT_NEW_ARCH_ENABLED
  _contextContainer = std::make_shared<facebook::react::ContextContainer const>();
  _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
  _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
  _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
  bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif

  UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"rtdadvisor", nil);

  if (@available(iOS 13.0, *)) {
    rootView.backgroundColor = [UIColor systemBackgroundColor];
  } else {
    rootView.backgroundColor = [UIColor whiteColor];
  }

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  [RNSplashScreen show];

  return YES;
}

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

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

#if RCT_NEW_ARCH_ENABLED

#pragma mark - RCTCxxBridgeDelegate

- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
  _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
                                                             delegate:self
                                                            jsInvoker:bridge.jsCallInvoker];
  return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}

#pragma mark RCTTurboModuleManagerDelegate

- (Class)getModuleClassFromName:(const char *)name
{
  return RCTCoreModulesClassProvider(name);
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                      jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
  return nullptr;
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                     initParams:
                                                         (const facebook::react::ObjCTurboModule::InitParams &)params
{
  return nullptr;
}

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
  return RCTAppSetupDefaultModuleFromClass(moduleClass);
}

#endif

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
  return [Orientation getOrientation];
}

@end

// FacebookLoginModule.m
#import <Foundation/Foundation.h>
#import "FacebookLoginModule.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>

@implementation FacebookLoginModule

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(faceBookLogin:(RCTPromiseResolveBlock)resolve
                      rejecter:(RCTPromiseRejectBlock)reject) {
    dispatch_async(dispatch_get_main_queue(), ^{
      
        FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
        
        [loginManager logInWithPermissions:@[
          @"public_profile",
              @"pages_show_list",
              @"pages_manage_ads",
              @"pages_read_engagement",
              @"leads_retrieval",
              @"ads_management",
              @"pages_manage_metadata",
              @"business_management"]
                        fromViewController:nil
                                   handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
            if (error) 
            {
                reject(@"login_error", @"Facebook login failed", error);
            } 
            else if (result.isCancelled)
            {
                reject(@"login_cancelled", @"Facebook login was cancelled", nil);
            } 
            else 
            {
                NSDictionary *loginResult = @{
                    @"token": result.token.tokenString ?: [NSNull null],
                    @"userID": result.token.userID ?: [NSNull null],
                    @"grantedPermissions": result.grantedPermissions.allObjects ?: @[],
                    @"declinedPermissions": result.declinedPermissions.allObjects ?: @[]
                };
                resolve(loginResult);
            }
        }];
    });
}

@end

// FacebookLoginModule.h
#import <React/RCTBridgeModule.h>

@interface FacebookLoginModule : NSObject <RCTBridgeModule>
@end
@AndersonGuerraSantos
Copy link

Hi there,

I'm also experiencing the same issue with the Facebook Login UI not scrolling properly.

@santyasm
Copy link

+1 😕

@vietvh1995
Copy link

+1

1 similar comment
@arunlbit
Copy link

+1

@sufian1999
Copy link
Author

The issue is resolved with the latest Facebook App.
But if the user wants to connect pages and there are many pages then the last one can't be selected because it goes down.

Screenshot 2024-07-19 at 3 21 55 PM

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

No branches or pull requests

5 participants