我正在按照本教程将 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;
}