I'm trying to create a share via Facebook feature in my app.
Following the tutorials on facebook developers' site, I setup my project and the login works fine.
I cannot however make the request more permissions work. I need to ask the user for publish_actions permissions in order to be able to post on his behalf from my app.
I have for example the following active session:
2014-06-02 10:44:56.729 facebook[68183:60b] activeSession: , expirationDate: 2014-07-28 14:50:04 +0000, refreshDate: 2014-05-30 11:03:01 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:( installed, "public_profile" )>
and my code to try to share is:
[FBRequestConnection startWithGraphPath:@"me/permissions"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error){
NSDictionary *permissions= [(NSArray *)[result data] objectAtIndex:0];
if (![permissions objectForKey:@"publish_actions"]){
// Permission hasn't been granted, so ask for publish_actions
[FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound){
// Permission not granted, tell the user we will not share to Facebook
NSLog(@"Permission not granted, we will not share to Facebook.");
} else {
// Permission granted, publish the OG story
[self requestWithGraphPath:@"me/feed" andParams:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"http://www.in.gr",@"url",@"messageTitle",@"Titleos",@"description",@"description", nil] andHttpMethod:@"POST"];
}
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"Encountered an error requesting permissions: %@", error.description);
}
}];
} else {
// Permissions present, publish the OG story
[self requestWithGraphPath:@"me/feed" andParams:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"http://www.in.gr",@"url",@"messageTitle",@"Titleos",@"description",@"description", nil] andHttpMethod:@"POST"];
}
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"Encountered an error checking permissions: %@", error.description);
}
}];
Although I have already logged in, when I try to request the additional permissions, it asks me again to login instead just asking me to approve the additional permissions. On top of this, even if I login again, it does not grant me after all the publish_actions permissions.
How can I request successfully the necessary for publish permissions?
It turns out that using the latest Facebook sdk (3.1+ I think), publish actions work only for reviewed and submitted apps.
If you wanna test it, you have to make a test version of your app from the facebook dashboard.
They made it a bit annoying now. Make sure you have setup everything correct on your facebook app dashboard, otherwise you will get errors when trying to share stuff via your app.