PFFacebookUtils -

97 views Asked by At

I'm following this tutorial to integrate facebook login with messenger. When I'm compiling the first part of the code, I receive the error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must initialize PFFacebookUtils with a call to +initializeFacebookWithApplicationLaunchOptions'

I came across multiple threads including this one, however this was fixed in the new version I'm using already and thus can't be applied to fix my problem.

I hooked up a button that runs the tutorial code:

- (IBAction)loginWithFacebook:(id)sender
{
    // Set permissions required from the facebook user account
    NSArray *permissionsArray = @[ @"user_about_me", @"user_relationships", @"user_birthday", @"user_location"];

    // Login PFUser using Facebook
    [PFFacebookUtils logInInBackgroundWithReadPermissions:permissionsArray block:^(PFUser *user, NSError *error)
    {
        if (!user)
        {
            NSLog(@"Uh oh. The user cancelled the Facebook login.");
        }
        else if (user.isNew)
        {
            NSLog(@"User signed up and logged in through Facebook!");
        }
        else
        {
            NSLog(@"User logged in through Facebook!");
        }
    }];
}

Also, my AppDelegate.m has:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];


    return YES;
}
2

There are 2 answers

0
Jordan H On

That guide doesn't mention all of the required code to make it work. Parse does have more info in their iOS Guide. To resolve this issue specifically, in your didFinishLaunchingWithOptions method, replace your FBSDKApplicationDelegate call with the following:

[PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];
0
Sam On

I did some more research and stumbled upon this question. I combined it with Joey's answer and I got it to work.

First, I replaced

[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];

with

[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];

Then, I went to my info plist and change the LSApplicationQueriesSchemes type from string to array of strings and added item fbauth2