简体   繁体   中英

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 .

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 .

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.

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.

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

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.

This is because you have removed your app in facebook, even i am facing same problem. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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