Reputation: 2636
Facebook integration in my app works well. I ask for *read_stream* permission at login, then for *publish_actions* when I want to publish anything for the first time (as recommended).
The issue is, that when I ask for *publish_actions* permission, app switches to Facebook app and back. I wouldn't like user to see Facebook app, and I know many apps that post to the wall silently.
How can I do this?
Upvotes: 1
Views: 148
Reputation: 2722
You should ask for publish permission on login, not when publish something for the first time. Once the user is logged in with all needed permission, he won't see the fb app screen again (unless the session expired or is closed).
[FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
allowLoginUI:YES
completionHandler:aCompletionHandler];
Upvotes: 1
Reputation: 5148
if You did ask about public_action in the first time user login you not need it again. U need check active permission. If public_action found you not need call to get it a gain
// Ask for publish_actions permissions in context
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) {
// Permission hasn't been granted, so ask for publish_actions
[FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
if (FBSession.activeSession.isOpen && !error) {
// Publish the story if permission was granted
// write your code public here
}
}];
}
else {
// If permissions present, publish the story
// write your code public here
}
Upvotes: 1