Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Facebook SDK - Check Permissions

I have a Facebook SSO working perfectly on my app, using last release of Facebook Objective-C SDK. I need to ask an extra permission inside the app if user do "something". I don't need to ask that permission if user gave it to me before, so, I guess, in Facebook SDK there should be a method

-(BOOL) checkPermission:(NSString*) permission;

so I can use it like this:

if( [facebook checkPermission:@"email"] ) {

Is there a way to do this?

like image 308
Giorgio Marziani de Paolis Avatar asked Jan 13 '12 09:01

Giorgio Marziani de Paolis


2 Answers

This question is a bit old but you can now check what permissions the active session has without making a graph request. Here is how it's done in the HelloFacebookSample :

if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) {
    // permission does not exist
} else {
    // permission exists
}

Just replace "publish_actions" with "email".

like image 166
Raphaël Agneau de Selve Avatar answered Sep 22 '22 23:09

Raphaël Agneau de Selve


SDK not providing direct method for checking specific permissions but you can check if user granted permission to your application by checking permissions connection of user object in Graph API

GET https://graph.facebook.com/me/permissions

Same can be achieved with FQL query on permissions table

SELECT email FROM permissions WHERE uid = me()
like image 33
Juicy Scripter Avatar answered Sep 21 '22 23:09

Juicy Scripter