Search code examples
iosfacebookparse-platformauthenticationcompletion

iOS: Latest Parse SDK PFFacebookUtils blocks never gets executed


Using Parse SDK 1.9.1 and Facebook 4.8.0 I receive no callbacks and my completion blocks never get executed. I have all necessary things in my AppDelegate and everything went well until I upgraded my sdks.

examples in my code:

if (![PFUser currentUser]) {
    NSLog(@"!PFUser current user");
    NSArray *permissions = @[@"public_profile", @"email", @"user_friends"];

    [PFFacebookUtils logInInBackgroundWithReadPermissions:permissions block:^(PFUser *user, NSError *error) {
        NSLog(@"User:%@",[user description]);
        if (!user) {

            NSLog(@"Uh oh. The user cancelled the Facebook login.");
            NSLog(@"Uinfo :%@",[error userInfo][@"error"]);
        } else if (user.isNew) {
            NSLog(@"User signed up and logged in through Facebook!");
            [self updateUiForLoggedInUser];
            [self updateInstallationChannels];

        } else {
            NSLog(@"User logged in through Facebook!");
            [self updateUiForLoggedInUser];
            [self updateInstallationChannels];
        }
        if (error) {
            NSLog(@"Error trying to login:%@",[error description]);
        }
    }];
}

And also:

 if (![PFFacebookUtils isLinkedWithUser:[PFUser currentUser]]) {
    [PFFacebookUtils linkUserInBackground:[PFUser currentUser] withReadPermissions:nil block:^(BOOL succeeded, NSError *error) {
        if (succeeded) {
            NSLog(@"Woohoo, user is linked with Facebook!");
        }
    }];
}

Any idea why? Thanks in advance!

EDIT: I tried moving PFFacebookUtils logInInBackgroundWithReadPermissions: to another viewcontroller and it works fine. Any idea why it wont work on MainViewController?


Solution

  • I figured it out. Dunno why it happend but it seems that requests to FBFacebookUtils are now not asynchronous... I called linkUserInBackground right after loginInBackground and the response I got is only for linkUserInBackground. After separating those two methods everything works well.