在使用社交框架时,为Facebook获取错误ACErrorPermissionDenied(错误代码7) [英] Getting error ACErrorPermissionDenied (error code 7) for Facebook when using Social Framework

查看:198
本文介绍了在使用社交框架时,为Facebook获取错误ACErrorPermissionDenied(错误代码7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ACAccountStore 获取用户的Facebook帐户ID和名称。

I am fetching the user’s Facebook account ID and name using ACAccountStore.

当一个警报出现时用户权限(XYZ想访问您的新闻提要和配置文件),用户点击不允许,我得到错误代码7,即 ACErrorPermissionDenied

When an alert comes up asking the user for permission ("XYZ would like to access your news feed and profile") and the user taps on "Don’t Allow", I get error code 7, i.e ACErrorPermissionDenied.

但是之后,如果我转到设置并切换到我的应用程序的Facebook设置,然后在应用程序中弹出提醒,用户点按OK,我仍然收到错误代码7( ACErrorPermissionDenied )。所以在设置中启用了我在应用程序中点击确定,但仍然给我这个错误。

But after that, if I go to Settings and switch on the Facebook settings for my app and back in the app the alert pops up again and the user taps on "OK", I’m still getting error code 7 (ACErrorPermissionDenied). So it’s enabled in Settings and I’ve tapped "OK" in the app, but it’s still giving me this error.

如果第一个时间允许访问, 之后,可以从设置切换访问权限,这样可以给出正确的错误或成功。仅当用户第一次点击不允许时才会出现此问题。如果他在应用程序中不允许它,那么他将无法允许FB访问我的应用程序。

If the first time I allow access and after that switch access on or off from Settings, it gives me the proper error or success. This problem occurs only if the user taps "Don’t Allow" the first time. If he doesn’t allow it in the app when it asks, then he will not be able to allow FB access to my app.

我已经在iOS上测试了6.0和6.0.1使用以下代码:

I’ve tested this on iOS 6.0 and 6.0.1 using the following code:

 NSMutableArray *acAccountArray = [[NSMutableArray alloc] init];

ACAccountStore *accountStore = [[ACAccountStore alloc] init];

ACAccountType *accountType =
[accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[accountStore
 requestAccessToAccountsWithType:accountType
 options:[self getOptionDictionary:ACAccountTypeIdentifierFacebook permission:[[NSArray alloc]initWithObjects:@"read_stream",@"user_about_me",@"email", nil]]
 completion:^(BOOL granted, NSError *error) {
     if(granted) {
         // Doing what I want

     } else {
         NSLog(@"Error: %@", error);
     }
 }];



-(NSDictionary *)getOptionDictionary:(NSString * const)accountTypeIdentifier
                      permission:(NSArray*)permissionArray {
NSDictionary *options = nil;
if (accountTypeIdentifier == ACAccountTypeIdentifierFacebook) {
    options = @{
    @"ACFacebookAppIdKey" : @"dhksadhakjdhkshd",
    @"ACFacebookPermissionsKey" : permissionArray,
    @"ACFacebookAudienceKey" : ACFacebookAudienceFriends};
}
return options;}


推荐答案

你的应用程序是否仍然在Facebook的沙箱模式?如果是,只有管理员和开发人员才可见。如果您使用非管理员登录到您的设备上的应用程序,您可能会收到此错误。禁用沙箱模式解决了我的问题。

Is your app still in "sandbox mode" on Facebook? If yes, it will be visible only to administrators and developers. If you're logged in to Facebook on your device with a non-administrator for your app, you might receive this error. Disabling the sandbox mode fixed the problem for me.

这篇关于在使用社交框架时,为Facebook获取错误ACErrorPermissionDenied(错误代码7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆