3

I am trying to follow the Facebook SDK 3.1 tutorial: Scrumptious and integrate FB to my app.

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {

NSArray *permissions = @[@"email"];

return [FBSession openActiveSessionWithReadPermissions:permissions
                                          allowLoginUI:allowLoginUI
                                     completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                         [self sessionStateChanged:session state:state error:error];
                                     }];

I want to add extra permission however it only show the basic information in the authentication as the following image:

screenshot

I also used deprecated method and I got the same result:

[FBSession openActiveSessionWithPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
    [self sessionStateChanged:session state:state error:error];
}];

I found temporary solution from here by using reauthorizeWithPublishPermissions in somewhere else. The user have to login to the facebook twice to read the user email.

Is there any solution which I can do it in once?

Thanks for helping!

EDIT: Another post on stackoverflow, using openActiveSessionWithPublishPermissions, still have the same result as the screenshot.

Community
  • 1
  • 1
EES
  • 1,584
  • 3
  • 20
  • 38

3 Answers3

5

According to the Facebook FBSession Reference, as a best practice, you should ask for read permissions when opening the session. And then ask for additional permissions later on, when you need them.

It is required that initial permissions requests represent read-only permissions only.

Secondly, I tried this code below, and I get the right permission requirement.

NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];

[FBSession openActiveSessionWithReadPermissions:permissions
                                   allowLoginUI:YES
                              completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
 [self sessionStateChanged:session state:state error:error];}];
 [permissions release];

Hope this helps.

Snaker
  • 735
  • 9
  • 20
  • 1
    Thanks for the solution, I found out a interesting point is: when testing on iOS6, it read the permission on facebook.com; when testing on iOS5, it read the permission on the device. – EES Oct 24 '12 at 11:09
2

I would check the permissions on Facebook.com in the Facebook app's permission settings and make sure they match. I do believe they say you can set the permissions in your iOS code, but I would recommend matching the permissions in the FB app settings as well.

runmad
  • 14,846
  • 9
  • 99
  • 140
  • Thanks for your answer, I added email to the permission page. The result is still the same. – EES Oct 19 '12 at 07:59
  • Hi @runmad, IT WORKS!, after adding the permission page, and changing the parameter of '[self openSessionWithAllowLoginUI:YES]' to YES. – EES Oct 22 '12 at 06:53
2

http://developers.facebook.com/docs/reference/login/#permissions

this is an example how to use them

NSArray *permissions = [[NSArray alloc] initWithObjects:@"publish_stream", @"email", nil];
[facebook authorize:permissions];
[permissions release];
iArezki
  • 1,273
  • 2
  • 17
  • 29
  • 1
    I read this page and I understand there is some way to create the facebook instance. However when I was following the tutorial in facebook, they don't have to create the facebook instance. Is it possible for you to show how to create the facebook instance using the 3.1 fb sdk? – EES Oct 18 '12 at 15:50