我一直在搜索Google和SO,並找不到com.apple.accounts錯誤代碼8的含義。我正在嘗試使用iOS 6和Facebook SDK。當調用[ACAccountStore requestAccessToAccountsWithType]時獲取「錯誤代碼8」 - iOS Facebook
我運行此請求;
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) {
if (granted) {
NSLog(@"Success");
NSArray *accounts = [_accountStore accountsWithAccountType:fbActType];
_facebookAccount = [accounts lastObject];
} 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.)"
不管我做什麼,從不granted
返回true。任何想法將非常感激。
如果我繞過if(granted)
和調用這個函數:
- (void)me{
NSLog(@"Home.m - (void)me");
NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me"];
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:meurl
parameters:nil];
merequest.account = _facebookAccount;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"%@", meDataString);
}];
然後我看到這個JSON是由Facebook的返回: {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}}
更新:所以,錯誤的意思是」客戶端訪問信息字典的值不正確或缺失。「但我不知道這意味着什麼。
在設備或SIM? – Undo 2013-05-09 17:53:12
運行iOS 6.0的iPod Touch – Chris 2013-05-09 17:55:03
在設置中登錄到FaceBook,對不對? – Undo 2013-05-09 17:56:09