FacebookSDK introduces user interface twice

Using iOS 6 with the FacebookSDK splits read requests and permissions into two separate calls. I'm not sure why this is of any use, but it seems that I need to introduce the user with the Facebook interface twice for the first time.

In my application, I do not request anything from Facebook until the user wants to use Facebook, in which case they are first provided with a user interface for obtaining read permissions, and then for publishing permissions. Control switches from my application to facebook (for reading), back to my application, and then immediately returns to facebook (for publishing), and then back to my application.

This is a terrible user experience, especially because the facebook screen with โ€œGoodโ€ looks the same to the user. (Why do I double click Okay?)

My code in a nutshell:

Check for a valid FBSession.activeSession if not open call FBSession openActiveSessionWithReadPermissions if successful call FBSession.activeSession reauthorizeWithPublishPermissions then publish post 

The code works, but the user interface is disgusting. Am I missing something?

+4
source share
1 answer

I understand that iOS 6 requires a double login to support ACAccountStore , so the Facebook login tutorial implies that you must do this for all cases. Switching the application twice is a bad user interface, and I think I came up with a job.

First, for older iOS (e.g. iOS 5.0), you can simply use openActiveSessionWithPublishPermissions: and execute read and publish permissions in one fell swoop. Secondly, the same call works if the user has never accessed Facebook from the deviceโ€™s settings. Therefore, the following code works as follows:

  • If the user has registered on Facebook from the device settings: one dialogue for read and one dialogue for publication.
  • If the user has the Facebook application installed: switch to the FB application once and get 2 tips in a row.
  • Otherwise: switch for Safari once and get 2 prompts per line

I tested this code on iOS6 and iOS5 device using Facebook SDK 3.2.1

 - (BOOL)hasFacebookInDeviceSettings { ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountTypeFB = [accountStore accountTypeWithAccountTypeIdentifier:@"com.apple.facebook"]; BOOL hasFacebookBuiltinAccount = (accountTypeFB != nil); return hasFacebookBuiltinAccount; } - (BOOL)hasLoggedInToFacebookInDeviceSettings { if (![self hasFacebookInDeviceSettings]) { return NO; } BOOL result = [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]; return result; } - (void)openFacebookSessionWithAllowLoginUI:(BOOL)allowLoginUI { if (![self hasLoggedInToFacebookInDeviceSettings]) { // Simpler if we don't have the built in account [FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"] defaultAudience:FBSessionDefaultAudienceFriends allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { [self facebookSessionStateChanged:session state:state error:error]; }]; } else if (!FBSession.activeSession.isOpen) { __block BOOL recursion = NO; [FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { if (recursion) { return; } recursion = YES; if (error || !FBSession.activeSession.isOpen) { [self facebookSessionStateChanged:session state:state error:error]; } else { assert(FBSession.activeSession.isOpen); if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) { [FBSession.activeSession requestNewPublishPermissions:@[@"publish_actions"] defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(FBSession *session, NSError *error) { [self facebookSessionStateChanged:session state:FBSession.activeSession.state error:error]; }]; } } }]; } } 

hasFacebookInDeviceSettings reports whether this device even supports Facebook features (for example, this is iOS6 +).

hasLoggedInToFacebookInDeviceSettings reports that the user has signed a contract with Facebook using the iOS6 Facebook device settings.

You will need to create your own facebookSessionStateChanged: and another code as described in the login tutorial

+1
source

All Articles