我将 Parse 和 Facebook iOS SDK 都更新到了最新版本,当我尝试使用 Facebook 登录时,我的应用程序崩溃了,从调试器中我可以看到它正在无限循环中调用 3-4 个方法。
我的登录代码如下所示:
- (void)openSession
{
UIViewController *topViewController = self.window.rootViewController;
NSArray *permissions = [NSArray arrayWithObjects:@"user_likes", @"friends_likes", nil];
// Login PFUser using Facebook
[PFFacebookUtils logInWithPermissions:permissions block:^(PFUser *user, NSError *error) {
if (!user) {
if (!error) {
NSLog(@"Uh oh. The user cancelled the Facebook login.");
} else {
NSLog(@"Uh oh. An error occurred: %@", error);
}
} else if (user.isNew) {
NSLog(@"User with facebook signed up and logged in!");
if ([[topViewController presentedViewController] isKindOfClass:[PALoginViewController class]]) {
[topViewController dismissViewControllerAnimated:YES completion:nil];
}
} else {
NSLog(@"User with facebook logged in!");
if ([[topViewController presentedViewController] isKindOfClass:[PALoginViewController class]]) {
[topViewController dismissViewControllerAnimated:YES completion:nil];
}
}
}];
}
logInWithPermissions
调用时发生错误。它崩溃到 Xcode 并且 Debugger 显示了大量对 FB 登录方法的调用 - 实际上有数千个:
有什么问题?