FBSessionStateClosedLoginFailed upon login through Settings

I have a facebook integration application and sometimes everything works fine, but now I have mail that some people cannot log into Facebook.

Now what am the problem now.

If I did not log in through the setup in my facebook account, everything works fine, but when I logged in through the setup, I always get the sessionStateChanged case in sessionStateChanged funciton FBSessionStateClosedLoginFailed:

What can I do against this?

Here is my code:

First, when I click on the Facebook login, I use this function:

 - (void)facebookLoginFunction { if ([self checkInternet]==TRUE) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionStateChanged:) name:FBSessionStateChangedNotification object:nil]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; // The person using the app has initiated a login, so call the openSession method // and show the login UX if necessary. [appDelegate openSessionWithAllowLoginUI:YES]; } } 

and sessionStateChanged function: in delegate

 - (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error{ switch (state) { case FBSessionStateOpen: if (!error) { // We have a valid session NSLog(@"User session found"); } break; case FBSessionStateClosed: NSLog(@"User session closed"); case FBSessionStateClosedLoginFailed:{ NSLog(@"Login failed"); [FBSession.activeSession closeAndClearTokenInformation];} break; default: break; } [[NSNotificationCenter defaultCenter] postNotificationName:FBSessionStateChangedNotification object:session]; if (error) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } } 

I really hope you can help me because I do not understand this crazy problem. thanks

+4
source share
1 answer

Adding both

 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return [FBSession.activeSession handleOpenURL:url]; } - (void)applicationDidBecomeActive:(UIApplication *)application { [FBSession.activeSession handleDidBecomeActive]; } 

Worked!

All loans go to Skrew for an answer.

+3
source

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


All Articles