在iOS 6.0和iOS 6.0.1上调用[FBSession openActiveSessionWithPermissions ...]时从ACAccountStore抛出NSInvalidArgumentException [英] NSInvalidArgumentException thrown from ACAccountStore when calling [FBSession openActiveSessionWithPermissions...] on iOS 6.0 and iOS 6.0.1

查看:184
本文介绍了在iOS 6.0和iOS 6.0.1上调用[FBSession openActiveSessionWithPermissions ...]时从ACAccountStore抛出NSInvalidArgumentException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Facebook iOS SDK 3.1.1,我正在使用此调用执行登录 -

With Facebook iOS SDK 3.1.1, I'm performing login using this call -

NSArray *permissions = [[NSArray alloc] initWithObjects: @"email", @"user_birthday", @"user_location", nil];

@try {
    return [FBSession openActiveSessionWithReadPermissions:permissions
                                              allowLoginUI:allowLoginUI
                                         completionHandler:^(FBSession *session,
                                                             FBSessionState state,
                                                             NSError *error) {
                                             [self sessionStateChanged:session
                                                                 state:state
                                                                 error:error];
                                         }];
}
@catch { ... }

极少数情况下此方法抛出 NSInvalidArgumentException ,并带有消息此帐户类型不允许访问选项。 options参数必须为nil。,这是从 [ACAccountStore requestAccessToAccountsWithType:options:completion:] 抛出的。

There are rare cases when this method throws NSInvalidArgumentException with message Access options are not permitted for this account type. The options argument must be nil., this is thrown from [ACAccountStore requestAccessToAccountsWithType:options:completion:].

检查Apple的 ACAccountStore 的文档,我看到这个方法的评论:

Checking the Apple's docs of ACAccountStore, I see this comment for that method:

某些帐户类型(如Facebook)需要一个选项字典。如果没有为此类帐户类型提供选项字典,此方法将抛出NSInvalidArgumentException。相反,如果帐户类型不需要选项字典,则options参数必须为没有。

"Certain account types (such as Facebook) require an options dictionary. This method will throw an NSInvalidArgumentException if the options dictionary is not provided for such account types. Conversely, if the account type does not require an options dictionary, the options parameter must be nil."

除了Facebook之外,Apple要求这是零,但这种方法是从Facebook调用的,所以也许这是一个错误 - 无论是在Facebook还是在iOS 6.0 /.1,但我在网上找不到关于这个问题的任何内容。

Apple require this to be nil except for Facebook, but this method IS called from Facebook, so Maybe this is a bug - either at Facebook or at iOS 6.0/.1, but I couldn't find anything on the web about this issue.

任何想法?

推荐答案

我找到了解决这个bug的方法。请注意,此处还描述了该错误: https://developers.facebook.com/bugs/139251032898548

I found a work around for this bug. Note that the bug is described here as well: https://developers.facebook.com/bugs/139251032898548

Facebook SDK不会对accountTypeWithAccountTypeIdentifier的返回值进行空检查。请参阅 https:// github。 com / facebook / facebook-ios-sdk / blob / master / src / FBSystemAccountStoreAdapter.m?source = c#L176

The Facebook SDK does not do a null check for return value of accountTypeWithAccountTypeIdentifier. See https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBSystemAccountStoreAdapter.m?source=c#L176

要解决此问题,你可以在尝试facebook lgoin之前做以下检查:

To work around the problem, you can do the following check before attempting facebook lgoin:

if ([[[ACAccountStore alloc]init] accountTypeWithAccountTypeIdentifier:@"com.apple.facebook"] == nil) {
   NSLog(@"Cannot proceed, not facebook account type identifier");
   return;
}

这篇关于在iOS 6.0和iOS 6.0.1上调用[FBSession openActiveSessionWithPermissions ...]时从ACAccountStore抛出NSInvalidArgumentException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆