objective-ciosfacebookfacebook-graph-apifbrequest-form

Check Facebook Permissions on iOS


I've seen this post which describes how to use the graph api to check a user's permissions, however I'm not sure how to actually check a specific permission.

Calling [facebook requestWithGraphPath:@"me/permissions" andDelegate:self]; calls the delegate method - (void)request:(FBRequest *)request didLoad:(id)result but how best to handle the response? I already have two blocks in this delegate which handle other types of requests, specifically by calling if ([result isKindOfClass:[NSArray class]]) and if ([result isKindOfClass:[NSDictionary class]]) Presumably the FBRequest for permissions is also an Array, so how can I distinguish it from other FBRequest arrays? And once I have the array, how do I check a specific permission - in my case publish_stream.

Also, is this the quickest way to do it? I want to check if this permission is active and if not, prompt the user to log in again. Currently I check if the session needs validating by calling if (![facebook isSessionValid]) so I could change this to something like if (![facebook isSessionValid] || ![self checkPermissions] but this would require a full request call.


Solution

    1. For your first question try using another delegate for this purpose only (i.e. create a class which implements the FBRequestDelegateprotocol and implement the required request method) and pass this delegate to the graph request call.

    2. You can try iterating the Array and find a match to the required permissions.