Facebook iOS选择朋友表空白

我正在尝试将“选择朋友”添加到我的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]; } 

在打开朋友选择控制器之前,请通过调用以下内容确保您的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 }]; } 

即使您非常了解Facebook SDK的其余部分,您仍需要处理两件事情,即使您不了解自己需要这些东西。

  1. 该对话框仅显示已安装该应用程序的朋友。
  2. 您必须在登录流程中询问user_friends权限。

对于1.,创建或使用您已有的测试用户并与该用户一起运行您的应用程序,以便授权该应用程序进行基本访问(“安装”它)。

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

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

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

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