Nir Nir - 2 months ago 187
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];
[login
logInWithReadPermissions: @[@"public_profile", @"email"]
fromViewController:self
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) {
NSLog(@"Cancelled");
[self hideLoader];
[self showError:@"Error" message:@"Please try to use other login option"];
} else {
[self loginButton:sender didCompleteWithResult:result error:error];
NSLog(@"Logged in");
}
}];
}


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


My app using this library for slide navigation: https://github.com/aryaxt/iOS-Slide-Menu

There is two options to show the
loginViewController
screen:

1.
From regular screen (inherit from
UIViewController
), 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.

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


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: https://developers.facebook.com/docs/ios/getting-started

  2. Enable keychain sharing - using this: http://stackoverflow.com/a/38799196/867694



The only thing that I have in the log when the
loginViewController
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

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];
Comments