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 { ... }
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:]
.
Checking the Apple's docs of ACAccountStore
, I see this comment for that method:
"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."
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.
Any ideas?
I found a work around for this bug. Note that the bug is described here as well: https://developers.facebook.com/bugs/139251032898548
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
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With