I have updated iPhone 6 plus to iOS 9 beta and trying to perform Facebook login but each time its presenting UIWebView with Facebook login form.
I have Facebook sdk
FB_IOS_SDK_VERSION_STRING @"3.24.0"
FB_IOS_SDK_TARGET_PLATFORM_VERSION @"v2.2"
And I am using following methods to perform Facebook Login
NSArray *permissions = @[@"email",@"user_birthday",@"public_profile"];
FBSessionStateHandler completionHandler = ^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session state:status error:error];
};
if ([FBSession activeSession].state == FBSessionStateCreatedTokenLoaded) {
// we have a cached token, so open the session
[[FBSession activeSession]openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent
fromViewController:nil
completionHandler:completionHandler];
} else {
[self clearAllUserInfo];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
// create a new facebook session
FBSession *fbSession = [[FBSession alloc] initWithPermissions:permissions];
[FBSession setActiveSession:fbSession];
[fbSession openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent
fromViewController:nil
completionHandler:completionHandler];
}
I have following setting under plist file
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fb-messenger-api20140430</string>
<string>fbauth</string>
<string>fbauth2</string>
<array>
Please let me know what I am missing here. First it is checking for iPhone device Setting-> Facebook credentials
but never open Facebook app for login. Seems it does not recognize Facebook app installed on device.
Best Answer
Below is complete process for new "Facebook login".
this is how I have revised my Facebook Login integration to get it work on latest update.
Step-1. Download latest Facebook SDK (it includes major changes).
Step-2. Add FBSDKCoreKit.framework and FBSDKLoginKit.framework to your project.
Step-3. Now go to Project > Build Phases > add SafariServices.framework
Step-4. There are three changes in info.plist we need to verify.
4.1 Make sure you have below in your info.plist file
4.2 Now add below for White-list Facebook Servers, this is must for iOS 9
4.3 Add URL schemes
Step-5. Now open AppDelegate.m file
5.1 Add below import statements, (remove old one).
5.2 update following following methods
Step-6. Now we need to modify our Login Controller, where we do Login task
6.1 Add these imports in Login ViewController.m
6.2 Add Facebook Login Button
6.3 Handle Login button click
6.4 Get user info (name, email etc.)
Step-7. Now you can build project, you should get below screen.
Hope this will help you guys.
References : Thanks to Facebook docs, Stackoverflow posts and Google.