Facebook ios6 completeHandler not called after login

I am trying to post to Facebook using openActiveSessionWithPublishPermissions , so if the user is not logged in, he needs to log in first and then post using the native io6 Facebook dialog.

What I found, I can log in, but the completion handler is not called.

Another thing that I noticed is that when I click on the login button again, it calls the exit handler with the following error FBSessionStateClosedLoginFailed .

I referred to this post , but still have not found 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; } }]; 
+6
source share
2 answers

Make sure you execute the handleOpenUrl method.

 -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [[FBSession activeSession] handleOpenURL:url]; } 
+5
source

You should add this:

 [FBNativeDialogs presentShareDialogModallyFrom:currentController initialText:nil image:nil url:nil handler:^(FBNativeDialogResult result, NSError *error) { if (result==FBNativeDialogResultCancelled) { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error" message:@"Sending Cancelled" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; } else if (result==FBNativeDialogResultSucceeded) { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Succeed" message:@"succeed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; }***}***]; 
0
source

Source: https://habr.com/ru/post/926585/


All Articles