iOS facebook 检查朋友是否安装了应用程序 [英] iOS facebook check if friends have app installed
问题描述
是否已经可以通过 facebook ios API 获取安装了您的应用的朋友列表?我基本上需要类似于与朋友交谈"的东西,他们可以在其中确定您的哪些 FB 朋友正在玩游戏.我有一个解决方案,它需要使用一些额外的数据库,但希望 FB api 可能为这种查询内置了一些东西.
Is there already a way with the facebook ios API to get a list of friends who have your app installed? I basically require something similar to "Words with Friends" where they can determine which of your FB friends are playing the game. I have one solution which requires some extra database use but was hoping maybe the FB api had something built in for this kind of query.
推荐答案
创建一个 FBFriendPickerDelegate
委托类并覆盖这个函数:
Create a FBFriendPickerDelegate
delegate class and override this function:
-(BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker shouldIncludeUser:(id<FBGraphUser>)user{
BOOL installed = [user objectForKey:@"installed"] != nil;
return installed;
}
对于没有安装您的应用程序的用户,installed
字段将为 nil
,但您必须在加载数据时请求它:
For users that do not have your app installed, installed
field will be nil
, but you have to request it when you load data:
self.friendsController = [[FBFriendPickerViewController alloc] initWithNibName:nil bundle:nil];
//...
NSSet *fields = [NSSet setWithObjects:@"installed", nil];
self.friendPickerController.fieldsForRequest = fields;
//...
[self.friendsController loadData];
这篇关于iOS facebook 检查朋友是否安装了应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!