據我瞭解,當我調用[ACAccountStore requestAccessToAccountsWithType:options:completion]
時,用戶應該看到一個UIAlert,詢問他們是否授予我的應用程序權限。iOS requestAccessToAccountsWithType不顯示權限提示/ NSAlert
當我運行這段代碼,從來就沒有提示和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設置有關...
的輸出是什麼數? – 2013-05-09 18:59:21
已更新的原帖 – Chris 2013-05-09 19:01:50
可能重複[獲取「錯誤代碼8」時調用\ [ACAccountStore requestAccessToAccountsWithType \] - iOS的Facebook](http://stackoverflow.com/questions/16425325/getting-error-code-8-when-主叫acaccountstore-requestaccesstoaccountswitht) – WrightsCS 2013-09-20 19:44:22