By default, FBSDKLoginBehavior.Native does not work on iOS 9

I just upgraded the app to Xcode 7 / Swift 2.0, and I'm afraid of logging into Facebook through AppSwitch. I am on the latest FBSDK (4.6) and have done everything in accordance with the upgrade guide . However, on iOS9, Facebook is logged in through the browser in the application, the application does not work anymore. I also tried getting the loginbehavior setting, but no luck:

let manager = FBSDKLoginManager() manager.loginBehavior = FBSDKLoginBehavior.Native manager.logInWithReadPermissions(facebookReadPermissions, fromViewController: nil, handler: { (loginResult, error) -> Void in 

Is there anything I can do to make appswitch work again?

Thanks!

+6
source share
2 answers

It turns out that this is not a problem, but the new desired behavior according to these Facebook posts:

https://developers.facebook.com/bugs/1636969533209725/?comment_id=1011596265571252

This is design behavior. In our latest iOS SDKs, login behavior is now controlled on the server side to provide a better user experience.

https://developers.facebook.com/bugs/786729821439894/?comment_id=1467419033584031

Due to the changes introduced in iOS 9, this new behavior avoids asking the user if they want to go and open the Facebook application, accept / share / etc permissions, and then ask again if they want to go back to your application.

https://developers.facebook.com/bugs/1390559277910338/?comment_id=1661064587442645

System authentication does not give people control over the information that they use with applications. And in iOS 9, a quick switch to the Facebook native application leads to additional dialog boxes (“ExampleApp would like to open Facebook”) that appear twice - once on the way from ExampleApp to Facebook and again on the way back. We believe that the default behavior of the SDK in v4.6 on iOS 9 provides the best experience for people signing in to your application using Facebook.

+9
source

You can fix the FacebookSDK source code to use Fast App Switching.

The interesting part (for tag 4.6) is in the file FBSDKCoreKit/Internal/ServerConfiguration/FBSDKServerConfigurationManager.m

 + (FBSDKServerConfiguration *)_defaultServerConfigurationForAppID:(NSString *)appID { … BOOL useNativeFlow = ![FBSDKInternalUtility isOSRunTimeVersionAtLeast:iOS9Version]; 

As you can see, this disables native thread on iOS9 +.
Changing a string to something like BOOL useNativeFlow = YES; should work.

PS I have not tested this patch yet.

0
source

All Articles