这是我的理解是,当我调用[ACAccountStore requestAccessToAccountsWithType:options:completion]
,用户应该看到,询问他们是否授予权限,我的应用程序的UIAlert。
当我运行这段代码,从来就没有提示和granted
变量始终是“假”
-(void)myfunction {
if (!_accountStore) _accountStore = [[ACAccountStore alloc] init];
ACAccountType *fbActType = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
(NSString *)ACFacebookAppIdKey, @"##########",
(NSString *)ACFacebookPermissionsKey, [NSArray arrayWithObject:@"email"],
nil];
[_accountStore requestAccessToAccountsWithType:fbActType options:options completion:^(BOOL granted, NSError *error) {
NSLog(@"Home.m - getFBDetails - Check 2");
if (granted == YES) {
NSLog(@"Success");
NSArray *accounts = [_accountStore accountsWithAccountType:fbActType];
_facebookAccount = [accounts lastObject];
[self me];
} else {
NSLog(@"ERR: %@ ",error);
// Fail gracefully...
}
}
];
}
而我得到的错误: ERR: Error Domain=com.apple.accounts Code=8 "The operation couldn't be completed. (com.apple.accounts error 8.)"
更新:我做了一些测试,如果我使用运行ACAccountTypeIdentifierTwitter
,我得到的提示连接到我的Twitter账户,所以我假定这是一些与我的Facebook设置...