I am running with an issue with using Facebook SDK(4.9.1) which opens in app browser for login if no system account present.
Login from system Facebook account works well. I am using the following code
FBSDKLoginManager *manager = [[FBSDKLoginManager alloc] init];
manager.loginBehavior = FBSDKLoginBehaviorSystemAccount;
[manager logInWithReadPermissions:@[@"public_profile",@"email",@"user_friends"] fromViewController:controller handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
success(kFacebookStatusFailed);
} else if (result.isCancelled) {
success(kFacebookStatusCancelled);
} else {
success(kFacebookStatusSuccess);
}
}];
I have correctly done all required info.plist settings defined here.
The problem is when it logs in using inapp browser, actually using SafariViewController found by debugging. It goes through all login process but in the end it stucks in a white blank screen and doesn't dismiss, see screenshot below
Have tried all possible steps but not able to get over it. But when I setup fresh project having nothing just the above login code and proper settings, all worked fine.
The only difference in the Fresh Project and Original Project is number of different frameworks used in the app, like Crashlytics, Fabric, Instabug, Google Frameworks etc. Is there any reason that I should suspect these framework that is causing problem, I think NO. So, what could be the problem, anyone who faced the same problem and can help me will be greatly appreciated.
Thank You.
I was having the same problem. Add this to your AppDelegate:
In AppDelegate.m
In application:didFinishLaunchingWithOptions:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
}
Add the following method to your AppDelegate.m:
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
I don't know if the SafariViewController
checks for the application:openURL:sourceApplication:annotation
but this worked for me.
Give it a try. I hope it works for you.
Source: https://developers.facebook.com/docs/ios/getting-started