Native Facebook App Does Not Open with Facebook Login in iOS 9

iOS : Login with Facebook and open Native Facebook app

From V4.6.0 it won't redirect to fb app. See below

(v4.6.0 - September 10, 2015) In addition, the SDK dialogs such as
Login, Like, Share Dialogs automatically determine the best UI based
on the device, including SFSafariViewController instead of Safari.
Follow the our Preparing for iOS 9 guide.

Sample Image

Facebook native login is not opening facebook app even if it's installed in device?

I have found a solution, but you should change something in FBSDKLogin pod. I was debugging the Pod and I realized that Facebook ask in the class FBSDKServerConfiguration for the server configuration for the app. It returns a JSON with some information to configure the Pod for our app. I realized that by default the JSON returns this dictionary:

 "ios_sdk_dialog_flows" =     {
default = {
"use_native_flow" = 0;
"use_safari_vc" = 1;
};
message = {
"use_native_flow" = 1;
};
};

By default the use_native_flow is 0, so when it saves the information in userDefaults for the next app launches.
So, when the app calls FBSDKLoginMananger login method and checks for the loginBehaviour in this method, the variable useNativeDialog returns NO. So the switch uses the next case. case FBSDKLoginBehaviorBrowser:

- (void)logInWithBehavior:(FBSDKLoginBehavior)loginBehavior
{
.
.
...
switch (loginBehavior) {
case FBSDKLoginBehaviorNative: {
if ([FBSDKInternalUtility isFacebookAppInstalled]) {
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration *serverConfiguration, NSError *loadError) {
BOOL useNativeDialog = [serverConfiguration useNativeDialogForDialogName:FBSDKDialogConfigurationNameLogin];
if (useNativeDialog && loadError == nil) {
[self performNativeLogInWithParameters:loginParams handler:^(BOOL openedURL, NSError *openedURLError) {
if (openedURLError) {
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
formatString:@"FBSDKLoginBehaviorNative failed : %@\nTrying FBSDKLoginBehaviorBrowser", openedURLError];
}
if (openedURL) {
completion(YES, FBSDKLoginManagerLoggerAuthMethod_Native, openedURLError);
} else {
[self logInWithBehavior:FBSDKLoginBehaviorBrowser];
}
}];
} else {
[self logInWithBehavior:FBSDKLoginBehaviorBrowser];
}
}];
break;
}
// intentional fall through.
}
case FBSDKLoginBehaviorBrowser: {
.
.
.

}

As we see in the code, we know if the app is installed in this if,
if ([FBSDKInternalUtility isFacebookAppInstalled]).
To solve the problem, I have changed this line

BOOL useNativeDialog = [serverConfiguration useNativeDialogForDialogName:FBSDKDialogConfigurationNameLogin];

to

 BOOL useNativeDialog = YES;

I know this is not a good practice and it will change if I update this Pod, but at least is working and I needed it now.
I guess we can change that configuration in facebook developers admin site, but I haven't found anything.

Facebook SDK login never calls back my application on iOS 9

Turns out that on iOS 9 when UIApplicationDelegate's application:openURL:options: is implemented, application:openURL:sourceApplication:annotation: will not get called.

So what I had to do is call FBSDKApplicationDelegate's application:openURL:sourceApplication:annotation: from UIApplicationDelegate's application:openURL:options:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
return [[FBSDKApplicationDelegate sharedInstance] application:app
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
}

Default FBSDKLoginBehavior.Native not working on iOS 9

Turns out that this is not an issue but the new desired behavior according to these posts from Facebook:

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

This behavior is by design. In our latest iOS SDKs, the login behavior is now controlled on the server side in order to ensure the best user experience.

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

Because of introduced changes in iOS 9, This new behavior avoids the user to be asked if they want to go and open the Facebook Application, accept the permissions/share/etc, and then ask once more if they want to switch back to your app.

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

System authentication doesn't give people control over the information they share with apps. And in iOS 9, fast-app-switching to the Facebook native app results in additional dialogs ("ExampleApp would like to open Facebook") which appear twice - once on the way from ExampleApp to Facebook, and once again on the return journey. We believe the default SDK behavior in v4.6 on iOS 9 offers the best experience to people logging into your app with Facebook.

Safari web view opening when logging to FB through iOS 9

From a product manager at Facebook in the "Facebook Developer Community" group.

Sample Image

And my Reply, still waiting for a response:

Sample Image

So it sounds like with SDK 4.6 they are forcing every login to use the Safari View Controller.

EDIT ----

And their response:
Sample Image



Related Topics



Leave a reply



Submit