用户位置返回空值

时间:2013-02-19 10:08:43

标签: iphone facebook ios6

在我的应用程序中,当我检索用户位置时,它返回一个Null值,而birthdate也返回Null值,Code如下,

 - (void)populateUserDetails {
if (FBSession.activeSession.isOpen) {
    [[FBRequest requestForMe] startWithCompletionHandler:
     ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error)           {
         if (!error) {
             self.userNameLabel.text = user.name;
             self.userProfileImage.profileID = [user objectForKey:@"id"];
             self.userbirthday.text=user.birthday;
             self.userloc=[[user objectForKey:@"location"]  objectForKey:@"name"];

         }
     }];
   }
 }

什么是rong代码?请帮我解决这个问题?

1 个答案:

答案 0 :(得分:2)

对于生日和地点,您需要获得此类许可。因此,您需要请求权限:Facebook SDK Documentation

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"user_location", // you need to have this permission
                            @"user_birthday", // to be approved
                            @"user_likes",
                            nil];
    return [FBSession openActiveSessionWithReadPermissions:permissions
                                              allowLoginUI:allowLoginUI
                                         completionHandler:^(FBSession *session,
                                                         FBSessionState state,
                                                         NSError *error) {
                                         [self sessionStateChanged:session
                                                             state:state
                                                             error:error];
                                     }];
}

然后使用FBRequest检索生日和位置。您可以访问用户名,因为它不需要特殊权限。