Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook ios6 completionHandler not called after signing in

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;
                    }
                }];
like image 883
NNikN Avatar asked Sep 29 '12 17:09

NNikN


1 Answers

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]; 

}
like image 86
atastrophic Avatar answered Nov 15 '22 11:11

atastrophic