I am trying to publish on Facebook using openActiveSessionWithPublishPermissions , so if the user is not logged in he need's to first sign in and then post the message using io6 Facebook native Dialog.
What I found is I am able to login, but completion handler is not called.
Another thing I noticed, that when I click the login button again, it then calls completion handler with the following error FBSessionStateClosedLoginFailed.
I did refer to this post but still did not find a solution to my problem.
NSArray *permissions = [NSArray arrayWithObjects:@"publish_stream", nil];
[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:
^(FBSession *session, FBSessionState status, NSError *error)
{
switch (status) {
case FBSessionStateOpen:
{
[FBNativeDialogs presentShareDialogModallyFrom:currentController initialText:nil image:nil url:nil handler:^(FBNativeDialogResult result, NSError *error) {}];
}
break;
default:
break;
}
}];
Make sure you implemented the handleOpenUrl
method.
-(BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSession activeSession] handleOpenURL:url];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With