2

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.

Community
  • 1
  • 1
Smikey
  • 8,106
  • 3
  • 46
  • 74

1 Answers1

2
  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.

giorashc
  • 13,691
  • 3
  • 35
  • 71
  • Is implementing a whole new class really necessary?? Why can't I do it within the same class? And when you say find a match to the required permissions, does that mean that if a permission has been granted, it simply exists as a string inside the array? – Smikey Feb 29 '12 at 15:31
  • It is necessary if you want your code to be cleaner. You said yourself that you already have two blocks handling each request and just adding more will bloat you request handling method. – giorashc Mar 02 '12 at 20:19