ios – ACAccountStore错误6(ACErrorAccountNotFound)和8

ios – ACAccountStore错误6(ACErrorAccountNotFound)和8,第1张

概述我试图使用以下代码从ACAccountStore获取帐户: - (void) facebookLoginOnSuccess: (void (^)(void)) successBlock onError:(void(^)(NSError *error))errorBlock{ self.facebookPermissions = @[ @"offline_access", 我试图使用以下代码从ACAccountStore获取帐户:
- (voID) facebookLoginonSuccess: (voID (^)(voID)) successBlock onError:(voID(^)(NSError *error))errorBlock{    self.facebookPermissions = @[        @"offline_access",@"publish_stream",@"user_birthday",@"user_location",@"email"    ];    NSDictionary *options = @{        @"ACFacebookAppIDKey": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FacebookAppID"],@"ACFacebookAppVersionKey": @"1.0",@"ACFacebookPermissionsKey": self.facebookPermissions,@"ACFacebookPermissionGroupKey": @"write"    };    [self accountLoginFor:ACAccountTypeIDentifIErFacebook withOptions:options OnSuccess:successBlock onError:errorBlock];}- (voID) accountLoginFor: (Nsstring *) accountTypeID withOptions: (NSDictionary *) options OnSuccess: (voID (^)(voID)) successBlock onError:(voID(^)(NSError *error))errorBlock{    ACAccountStore *accountStore = [[ACAccountStore alloc] init];    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIDentifIEr:accountTypeID];    [accountStore requestAccesstoAccountsWithType:accountType                                          options:options                                       completion:^(BOol granted,NSError *error){        if (granted){            NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];            NSLog(@"%@",accountsArray);        }        else {            NSLog(@"Error accessing account: %@",[error localizedDescription]);        }    }];}

但是我收到这个错误

Error Domain=com.apple.accounts Code=6 "The operation Couldn't be completed. (com.apple.accounts error 6.)"

而且我找不到任何有关的东西,只是这个question.任何想法可能是错的?

更新

我在Apple Developer Docs上发现了这一点.

Accounts Framework

When requesting access to Facebook accounts,the only key required in your options dictionary is ACFacebookAppIDKey. ACFacebookPermissionGroupKey and ACFacebookAppVersionKey are Now obsolete.

If you request a write permission under ACFacebookPermissionsKey,such as publish_stream,you must provIDe a value for ACFacebookAudIEnceKey,which can be one of ACFacebookAudIEnceEveryone,ACFacebookAudIEnceFrIEnds,or ACFacebookAudIEnceOnlyMe.

所以我改变了我的选择:

NSDictionary *options = @{        @"ACFacebookAppIDKey": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FacebookAppID"],@"ACFacebookAudIEnceKey": ACFacebookAudIEnceFrIEnds    };

但我收到同样的错误.

解决方法 好的,所以如果你没有在iOS 6中设置一个帐户,它将抛出错误代码6.如果用户只是拒绝许可而不是抛出错误代码7.如果我建议你请求用户首先设置她的帐户设置.
NSDictionary *options = @{ACFacebookAppIDKey: @"1234567890",ACFacebookPermissionsKey: @[@"publish_stream"],ACFacebookAudIEnceKey: ACFacebookAudIEnceFrIEnds};[self.accountStore requestAccesstoAccountsWithType:facebookAccountType options:options completion:^(BOol granted,NSError *error){    if (granted)    {        NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];        if([accounts count]>0)            self.facebookAccount = [accounts lastObject];    }    else    {        dispatch_async(dispatch_get_main_queue(),^{            // Fail gracefully...            NSLog(@"%@",error.description);            if([error code]== ACErrorAccountNotFound)                [self throwAlertWithTitle:@"Error" message:@"Account not found. Please setup your account in settings app."];            else                [self throwAlertWithTitle:@"Error" message:@"Account access denIEd."];        });    }}];
总结

以上是内存溢出为你收集整理的ios – ACAccountStore错误6(ACErrorAccountNotFound)和8全部内容,希望文章能够帮你解决ios – ACAccountStore错误6(ACErrorAccountNotFound)和8所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1097320.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存