简体   繁体   English

使用Social Framework时获取Facebook的错误ACErrorPermissionDenied(错误代码7)

[英]Getting error ACErrorPermissionDenied (error code 7) for Facebook when using Social Framework

I am fetching the user's Facebook account ID and name using ACAccountStore . 我使用ACAccountStore获取用户的Facebook帐户ID和名称。

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, ie ACErrorPermissionDenied . 当出现警告要求用户许可(“XYZ想要访问您的新闻源和个人资料”)并且用户点击“不允许”时,我收到错误代码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 ). 但在那之后,如果我转到设置并打开我的应用程序的Facebook设置并返回应用程序,警报再次弹出,用户点击“确定”,我仍然收到错误代码7( ACErrorPermissionDenied )。 So it's enabled in Settings and I've tapped “OK” in the app, but it's still giving me this error. 因此它在设置中启用我已经在应用轻拍“OK”,但它仍然给我这个错误。

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. 如果他在请求时不允许它在应用程序中,那么他将无法允许FB访问我的应用程序。

I've tested this on iOS 6.0 and 6.0.1 using the following code: 我已经使用以下代码在iOS 6.0和6.0.1上测试了这个:

 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;}

Is your app still in "sandbox mode" on Facebook? 您的应用仍在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. 如果您在设备上以非管理员身份登录到Facebook,则可能会收到此错误。 Disabling the sandbox mode fixed the problem for me. 禁用沙盒模式为我解决了问题。

This is because you have removed your app in facebook, even i am facing same problem. 这是因为您已经在Facebook中删除了您的应用,即使我遇到同样的问题。 If you try to login using any method other than iOS native login then it adds facebook app if it is not there or removed by the user in facebook settings but it is currently not happening if you try to login using iOS native login. 如果您尝试使用iOS本机登录以外的任何方法登录,那么它会添加Facebook应用程序(如果它不存在或在Facebook设置中被用户删除)但如果您尝试使用iOS本机登录进行登录,则当前不会发生这种情况。 Please inform me if you come across ant solution for this issue and also is their a way i can remove my app being listed in iOS facebook settings in this case because if i remove and then user retries for login then it works correctly. 如果你遇到这个问题的ant解决方案,请通知我,这也是他们可以删除我在iOS facebook设置中列出的应用程序的一种方式,因为如果我删除然后用户重试登录,那么它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM