Facebook SDK: openActiveSessionWithPermissions completeHandler not called

Using the code from Facebook, I implemented

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI { NSArray *permissions = [[NSArray alloc] initWithObjects: @"publish_actions", nil]; return [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { NSLog(@"error %@", error); [self sessionStateChanged:session state:state error:error]; }]; } 

It returns NO, which I understand, because this is the first login, and loginUI works (it sends the user to FB and asks them for permissions), and then returns, but the Handler completion block never starts. It just goes back to the app and nada.

+4
source share
3 answers

I assume that you are following the Embed the login stream in the Facebook SDK, but you should read this section again as it explains everything. Make sure you handle the openURL and handleOpenURL methods in the delegate. Also check openSessionWithAllowLoginUI almost always returns NO

+4
source

A little late, but just in case someone comes to check ...

Switching from openActiveSession to the openWithCompletionHandler instance method helped.

+4
source

from the official report

Handler

... If a block is provided, the FBSession object will call the block every time the session state changes.

I fixed this problem by allowing Open Graph installations and examining sample code from FB, such as these functions [FBSession.activeSession handleOpenURL: url] and [FBSession.activeSession handleDidBecomeActive];

0
source

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


All Articles