Search code examples
iosobjective-cfacebook-ios-sdk

Facebook iOS SDK, blank screen after authorization


I've been following the guide at facebook's dev site. So I got everything set up, the authorization seems to go well, however, when accepting the application and then pressing "Okay", the only thing I get is a blank screen with "Cancel" at the top.

I believe the issue is located in the sessionStateChanged-method. It should stop at this part (I think):

 switch (state) {
    case FBSessionStateOpen: {
        UIViewController *topViewController =
        [self.navController topViewController];
        if ([[topViewController modalViewController]
             isKindOfClass:[MyLoginViewController class]]) {
            [topViewController dismissModalViewControllerAnimated:YES];
        }
    }   break;

So, if the logging in and authorization is a success, this should happen, right? Well, according to my breakpoints, it never happens. Maybe that´s why may application never gets opened again?

Anyway, I'm thankful for any tips or advice I can get on this one.

EDIT: I've discovered that the problem is the openSession-method:

    - (void)openSession
{
    [FBSession openActiveSessionWithReadPermissions:nil
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session,
       FBSessionState state, NSError *error) {
         [self sessionStateChanged:session state:state error:error];//This never gets called!!!
     }];
}

The sessionStateChanged-method never gets called, I have no idea why.


Solution

  • Your application is never opened because you didn't create the URL schemes to redirect you back. See screenshot from FB documentation.enter image description here