Nir Nir - 1 year ago 446
iOS Question

Objective c - iOS 10 Facebook login blank screen

In my app there is an option to login with Facebook.

On iOS 9.3 it's works OK.

When I testing it on iOS 10.0.1, it's shows me a blank screen.
enter image description here

I'm using this code to start the login process:

- (void)FacbookLoginButtonPressed:(id)sender {

[self showLoader];

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
logInWithReadPermissions: @[@"public_profile", @"email"]
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
[self hideLoader];
[self showError:@"Error" message:@"Please try to use other login option"];
} else if (result.isCancelled) {
[self hideLoader];
[self showError:@"Error" message:@"Please try to use other login option"];
} else {
[self loginButton:sender didCompleteWithResult:result error:error];
NSLog(@"Logged in");

is my ViewController calls
that shows the button, it inherit from

My app using this library for slide navigation:

There is two options to show the

From regular screen (inherit from
), there is a button, that on click this codes run:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"loginScreen";
[self presentViewController:vc animated:YES completion:nil];

That work's fine, I'm able to login with Facebook successfully.

From other screen that also inherit from
, but this screen is the slide menu, and I have this code in the

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MenuViewController *menu = [sb instantiateViewControllerWithIdentifier:@"MenuViewController";
[SlideNavigationController sharedInstance].rightMenu = menu;

Using this option, the facebook login doesn't work (blank screen)

Action that I did in order to try make it works:

  1. Update to the latest facebook SDK - using this:

  2. Enable keychain sharing - using this:

The only thing that I have in the log when the
appears from the menu (2nd option) is this:

Presenting view controllers on detached view controllers is discouraged <loginViewController: 0x7622fb0>.

What can I do?

Nir Nir
Answer Source

I finally fixed it, in MenuViewController I changed the way to present the loginViewController to this:

[self.view.window.rootViewController presentViewController:vc animated:YES completion:nil];