据我了解,当我调用时[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.)"
更新:我做了一些测试,如果我使用 using 运行ACAccountTypeIdentifierTwitter
,我会提示连接到我的 Twitter 帐户,所以我假设它与我的 Facebook 设置有关......