Facebook iOS选择朋友表空白

时间:2013-03-09 18:11:13

标签: ios facebook

我正在尝试将“选择朋友”添加到我的iOS应用中。我设置了登录视图。一旦我登录,我打开朋友选择器,但它出现空白。我看到带有完成和取消按钮的表格,但没有朋友加载到表格中。

- (IBAction)selectFriendsButtonAction:(id)sender {
    if (self.friendPickerController == nil) {
        // Create friend picker, and get data loaded into it.
        self.friendPickerController = [[FBFriendPickerViewController alloc] init];
        self.friendPickerController.title = @"Select Friends";
        self.friendPickerController.delegate = self;
    }
    [self.friendPickerController loadData];
    [self.friendPickerController clearSelection];
    [self presentViewController:self.friendPickerController animated:YES completion:nil];

}

3 个答案:

答案 0 :(得分:1)

在打开朋友选择器控制器之前,请通过调用以下方式确保您的Facebook会话处于活动状态:

if (!FBSession.activeSession.isOpen) {
    // if the session is closed, then we open it here, and establish a handler for state changes
    [FBSession.activeSession openWithCompletionHandler:^(FBSession *session,
                                                         FBSessionState state,
                                                         NSError *error) {
        // Handle error
    }];
}

答案 1 :(得分:0)

即使您非常了解Facebook SDK的其他部分,您仍需要处理两件事情,即使您对Facebook SDK的其余部分理解得很清楚,也可能无法实现。

  1. 该对话框仅显示已安装该应用的朋友。
  2. 您必须在登录流程中询问user_friends权限。
  3. 对于1.,创建或使用您已有的测试用户并与该用户一起运行您的应用程序,以便授权该应用程序进行基本访问(“安装”它)。

    对于2,将该权限添加到您的登录流程,注销并返回您正在测试的发件人(可能是您自己的用户),如果即使那时您没有被提示授予它,请卸载该应用程序通过https://www.facebook.com/settings/?tab=applications

    http://www.brianjcoleman.com/tutorial-get-facebook-friends-in-swift/讨论了其中一些问题。 Facebook文档本身要么根本没有提到这两个问题,要么被埋没了。

答案 2 :(得分:0)

如果您使用" FBFriendPickerViewController",似乎返回也使用此APP的朋友。在Facebook文档中:在API Graph v2.0之后," me / friends"只会返回也使用该应用的朋友。我认为这就是朋友表空白的原因。

还有另一种选择,你可以使用" FBTaggableFriendPickerViewController"代替。但是,在获得数据之前,您的APP需要经过Facebook审核。 (https://developers.facebook.com/docs/graph-api/reference/v2.2/user/taggable_friends?locale=zh_TW