I have quick question:
this code snippet works:
NSArray *permissions = @[@"email", @"user_birthday"];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
And this doesn’t:
NSArray *permissions = @[@"email", @"user_birthday", @"gender"];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
I’m simply asking for the gender of the Facebook user and in first case I’ve got on my NSLog console: User session found which is great… but when I extend the permission and include gender in it, I’ve got UIAlertView with:
Error
The operation couldn’t be completed. (com.facebook.sdk error 2.)
What I am doing wrong? How to ask for permission to get user gender?
Look at the list of permissions –
genderis not one of them – gender is, however a field of the User object and is also exposed in thesexcolumn in theuserFQL table which you can access once the user has granted you the basic permission to access their data.A sample query (SDK agnostic) to return just the current user’s gender is simply
/me?fields=gender, the return value of which will beNote that it’s also returned in the default response when accessing a user, so you don’t need to specify it explicitly.
Also, some users may not have a gender defined (though i think this is relatively rare)