我正在使用用户的Facebook帐户ID和名称ACAccountStore.
当出现警报要求用户许可("XYZ想要访问您的新闻源和个人资料")并且用户点击"不允许"时,我会收到错误代码7,即ACErrorPermissionDenied.
但在那之后,如果我转到设置并打开我的应用程序的Facebook设置并返回应用程序,警报再次弹出,用户点击"确定",我仍然收到错误代码7(ACErrorPermissionDenied).因此它在设置中启用和我已经在应用轻拍"OK",但它仍然给我这个错误.
如果我第一次允许访问,并且在设置之后打开或关闭开关访问,它会给我正确的错误或成功.仅当用户第一次点击"不允许"时才会出现此问题.如果他在请求时不允许它在应用程序中,那么他将无法允许FB访问我的应用程序.
我已经使用以下代码在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 = @{ …Run Code Online (Sandbox Code Playgroud)