0

我正在按照教程将 facebook 登录与 Messenger 集成。当我编译代码的第一部分时,我收到错误:

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

我遇到了多个线程,包括这个线程,但是这在我已经使用的新版本中得到了修复,因此不能用于解决我的问题。

我连接了一个运行教程代码的按钮:

- (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!");
        }
    }];
}

另外,我的 AppDelegate.m 有:

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

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


    return YES;
}
4

2 回答 2

1

该指南没有提到使其工作所需的所有代码。Parse 在他们的iOS Guide中有更多信息。要专门解决此问题,请在您的didFinishLaunchingWithOptions方法中将您的FBSDKApplicationDelegate调用替换为以下内容:

[PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];
于 2015-12-22T05:28:18.930 回答
0

我做了更多的研究,偶然发现了这个问题。我将它与乔伊的答案结合起来,我让它发挥作用。

首先,我更换了

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

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

然后,我去了我的信息 plist 并将LSApplicationQueriesSchemes类型从字符串更改为字符串数组并添加了项目fbauth2

于 2015-12-22T18:44:07.837 回答