I'm following this tutorial
to implement the view preview post on Facebook SDK 3.1, but when I call this method
...
// Ask for publish_actions permissions in context
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound) {
// No permissions found in session, ask for it
[FBSession.activeSession
reauthorizeWithPublishPermissions:
[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
// If permissions granted, publish the story
[self publishStory];
}
}];
} else {
// If permissions present, publish the story
[self publishStory];
}
...
returns the following error:
* Terminating app due to uncaught exception 'com.facebook.sdk: InvalidOperationException', reason: 'FBSession: an attempt was made
??reauthorize permissions on an unopened session'
What is happening can? Thank you!
EDIT:
Ran my friend, thank you very much, but still have a detail ...When'll post the first time he asks to authorize the application I authorize this block of fall
/*
* open a new session with publish permission
*/
[FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceOnlyMe
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (!error && status == FBSessionStateOpen) {
[self publishStory];
}else{
NSLog(@"error");
//Here I get the error mentioned below
}
}];
}
with the error: error:
domain = com.facebook.sdk, code = 5
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…