iOS Facebook SDK - Check Permissions
Solution 1
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".
Solution 2
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()
Giorgio Marziani de Paolis
Sr. Solutions Architect @ Amazon Italia
Updated on July 27, 2022Comments
-
Giorgio Marziani de Paolis almost 2 years
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?
-
Giorgio Marziani de Paolis over 12 yearsThank you, based on your answer, I tried using the method
[facebook requestWithGraphPath:@"me/permissions" andDelegate:self];
. Implementing the delegate method it works perfectly. Thank you again -
Smikey about 12 yearsCould you add the code for your method to determine if the e-mail permission was active or not? What will 'email' be if the permission is granted?
-
Ferran Maylinch almost 10 years
[FBSession activeSession].permissions
returns the permissions you requested, not the active ones. Or at least that's what I saw. See my answer below. You need[FBRequestConnection startWithGraphPath:@"/me/permissions" completionHandler:...]
. -
Raphaël Agneau de Selve almost 10 yearsI cannot test right now but the documentation says otherwise : "The permissions granted to the access token during the authentication flow." developers.facebook.com/docs/reference/ios/current/class/…
-
Ferran Maylinch almost 10 yearsToday I updated my Facebook SDK pod from 3.9.0 to 3.15.1 and now
[FBSession activeSession].permissions
returns the right permissions and[FBRequestConnection startWithGraphPath:@"/me/permissions" completionHandler:...]
doesn't return them anymore (now it returns {status:granted, permission:installed}).