I’m developing an app that has to post some info to facebook. When I call
[[FBSession activeSession] openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self publishFacebookStory];
}];
or
[FBSession openActiveSessionWithPublishPermissions:publishPermissions defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (!error) {
[self publishFacebookStory];
}
}];
the app switches to safari, I get a message saying that the app has already been authorised. I press okay and it switches back to my app but the completion handlers are never called and I still dont have a valid access token at this point.
Any ideas? Any help is appreciated.
Thanks.
The issue is how your app knows how to post upon your app delegate’s invocation of
applicationDidBecomeActive. If you go through the Facebook Publish to Feed, it will also refer you back to Facebook login which shows you the appropriate changes toapplicationDidBecomeActive.Bottom line, you have to decouple the opening of the session with the publishing on your Facebook feed (either by opening the session before you present the user the option of posting to their feed or by keeping track of what the user wanted to post before the authorization is initiated and then using that to publish the information upon
applicationDidBecomeActive).