Reputation: 8236
In my iOS app, I just want to check if the user has granted the Facebook publish_stream permission.
I'm not sure how to handle the response to the call
[facebook requestWithGraphPath:@"me/permissions" andDelegate:self];
in my FBRequest delegate method. I've tried:
if (request == self.permissionRequest) {
NSString *key = [result objectForKey:@"publish_stream"];
DLog(@"Key: %@", key);
}
But I get null.
And if I try
id *key = [result objectForKey:@"publish_stream"];
int keyInt = [key integerValue];
DLog(@"Key: %i", keyInt);
I always get 0. Even when I know the permission is active...
Upvotes: 1
Views: 3120
Reputation: 598
Here's a working sample I did for create_events. Sure it could be used for others:
FBRequest *eventPostOK = [FBRequest requestWithGraphPath:@"me/permissions" parameters:Nil HTTPMethod:@"GET"];
[eventPostOK startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
BOOL canDoIt = FALSE;
if (!error)
{
FBGraphObject *data = [result objectForKey:@"data"];
for(NSDictionary<FBGraphObject> *aKey in data) {
canDoIt = [[aKey objectForKey:@"create_event"] boolValue];
}
}
else
NSLog(@"%@", error);
NSLog(@"%@", canDoIt ? @"I can create Events" : @"I can't create Events");
}];
Upvotes: 3
Reputation: 533
You can make an FBRequest with the open graph API with "me/permissions". It will return you a response with a dictionary where the key are the permissions. a value will be associated (1 = YES, 0 = NO)
Upvotes: 3