无法获取facebook-ios-sdk中user_birthday和user_hometown的权限

Kas*_*idi 3 facebook facebook-graph-api ios facebook-ios-sdk

我无法获得user_birthdayuser_hometown的权限.我之前尝试使用此代码但它只询问公共配置文件并忽略其他配置文件.

[FBSession openActiveSessionWithReadPermissions:@[@"public_profile",@"user_birthday",@"user_hometown"]
                                           allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (error) {
 NBAppDelegate* appDel = (NBAppDelegate*)`[UIApplication sharedApplication].delegate;
 [appDel sessionStateChanged:session state:status error:error];
}

if ([session isOpen]) {
    [self loginWithFBToken:session name:sender];
}

}];
Run Code Online (Sandbox Code Playgroud)

然后有人建议在获取公开个人资料后要求额外的权限,所以我甚至尝试了这个没有好处.

这是代码

- (void)loadFbDetails
{
    NSArray *permissionsNeeded = @[@"user_hometown", @"user_birthday"];
    // Request the permissions the user currently has
    [FBRequestConnection startWithGraphPath:@"/me/permissions"
       completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                          if (!error){
                              // These are the current permissions the user has:
                              NSDictionary *currentPermissions= [(NSArray *)[result data] objectAtIndex:0];

                              // We will store here the missing permissions that we will have to request
                              NSMutableArray *requestPermissions = [[NSMutableArray alloc] initWithArray:@[]];

                              // Check if all the permissions we need are present in the user's current permissions
                              // If they are not present add them to the permissions to be requested
                              for (NSString *permission in permissionsNeeded){
                                  if (![currentPermissions objectForKey:permission]){
                                      [requestPermissions addObject:permission];
                                  }
                              }

                              // If we have permissions to request
                              if ([requestPermissions count] > 0){
                                  // Ask for the missing permissions
                                  [FBSession.activeSession
                                   requestNewReadPermissions:requestPermissions
                                   completionHandler:^(FBSession *session, NSError *error) {
                                       if (!error) {
                                           // Permission granted
                                           NSLog(@"new permissions %@", [FBSession.activeSession permissions]);
                                           // We can request the user information
                                           [self makeRequestForUserData];
                                       } else {
                                           // An error occurred, we need to handle the error
                                           // See: https://developers.facebook.com/docs/ios/errors
                                       }
                                   }];
                              } else {
                                  // Permissions are present
                                  // We can request the user information
                                  [self makeRequestForUserData];
                              }

                          } else {
                              // An error occurred, we need to handle the error
                              // See: https://developers.facebook.com/docs/ios/errors
                          }
                      }];
Run Code Online (Sandbox Code Playgroud)

}

-(void)makeRequestForUserData
{
[FBRequestConnection startWithGraphPath:@"me?fields=birthday,hometown"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                          if (!error) {
                              // Sucess! Include your code to handle the results here
                              NSLog(@"user events: %@", result);
                          } else {
                              NSLog(@"error: %@" , error);
                          }
                      }];
}
Run Code Online (Sandbox Code Playgroud)

它只是递归地在我的ios应用程序和fb本机应用程序之间进行,只返回权限数组中的public_profile.

看起来我错过了什么?

Tob*_*obi 6

如果您正在使用该应用的管理员用户,它应该可以正常工作.一旦您想与其他用户一起使用扩展权限,您必须首先通过Facebook审核您的应用.

在这里看到我的答案:facebook扩展许可