Thursday, 8 August 2013

Facebook iOS SDK 3.6 startWithGraphPath completion block not executed

Facebook iOS SDK 3.6 startWithGraphPath completion block not executed

I've integrated with Facebook so that I can, among other things, post
statuses to my feed. I based some of my code off of the publish to feed
developer tutorial. When running the following Graph API request from my
iOS application the completion block of the request is never called and no
error appears in the XCode debug log.
[FBRequestConnection
startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError
*error) {
if (error) {
DLog(@"error: domain = %@, code = %d", error.domain, error.code);
} else {
DLog(@"Posted action, id: %@", result[@"id"]);
}
}];
I have two convenience functions that perform checks on the openSession I
currently have before executing this request. They look like this:
+ (BOOL)facebookSessionIsOpen {
return (FBSession.activeSession.isOpen);
}
+ (BOOL)facebookSessionHasPublishPermissions {
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound ||
[FBSession.activeSession.permissions
indexOfObject:@"publish_stream"] == NSNotFound ||
[FBSession.activeSession.permissions
indexOfObject:@"manage_friendlists"] == NSNotFound) {
return NO;
} else {
return YES;
}
}
Both of these functions return YES indicating an active session with the
necessary publishing permission. What's more confusing is that I can pull
the user's profile without issue after performing the same checks
successfully (granted publishing permissions are not required to pull the
profile) using the following code:
[FBRequestConnection
startWithGraphPath:@"me"
parameters:[NSDictionary
dictionaryWithObject:@"picture,id,birthday,email,location,hometown"
forKey:@"fields"]
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError
*error) {
NSDictionary* resultDict = (NSDictionary*)result;
NSString* emailAddress = resultDict[@"email"];
NSString* location = resultDict[@"location"][@"name"];
NSString* birthday = resultDict[@"birthday"];
NSString* homeTown = resultDict[@"hometown"][@"name"];
...
}];
Any suggestions on how to debug this issue?

No comments:

Post a Comment