iOS facebook check if friends have app installed

4 Solutions Collect From Internet About “iOS facebook check if friends have app installed”

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;

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];

I think fql is a little complex for me,so I use this function in FBRequest to call the Graph API to solve this problem in Facebook SDK 3.5

+ (FBRequest *)requestWithGraphPath:(NSString*)graphPath parameters:(NSDictionary*)parameters HTTPMethod:(NSString*)HTTPMethod;

And the code is:

FBRequest *request =  [FBRequest  requestWithGraphPath:@"me/friends"

[request startWithCompletionHandler:^(FBRequestConnection *connection,
                                     id result,
                                      NSError *error){


You can put all your interesting fields in the parameters dictionary.
And according to the SDK Reference,object containing type (this is always “user”), id (the ID of the user), and optional installed field (always true if returned); The installed field is only returned if the user has installed the application, otherwise it is not part of the returned object

I’ve used this code in the past to get app using friends from a user.

facebook is the Facebook class that comes with FB Connect.

NSString *fql = [NSString stringWithFormat:@"SELECT name,uid, pic_small FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = %@) order by concat(first_name,last_name) asc",userId,userId]];

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:fql ,@"query", [facebook accessToken], @"access_token", nil];

[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self];

The easiest solution is using the

- (BOOL)friendPickerViewController: shouldIncludeUser: 

method implemented by the FBFriendPickerDelegate protocol in the latest 3.5.1 Facebook SDK (June 2013), asking the delegate whether to include a friend in the list, based on the “installed” field when fetching me/friends.

The installed field is present (true) if the friend is also a user of the calling application.

You can use like this:

- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
                 shouldIncludeUser:(id <FBGraphUser>)user {
        return [[user objectForKey:@"installed"] boolValue];     

You have to include the followings to include the field in the request and to inform friendPicker about its delegate:

    self.fieldsForRequest = [NSSet setWithObject:@"installed"];
    self.delegate = self;

You can verify with the Graph Api Explorer that only friends with the apps installed display by using the Graph API Explorer and entering the query


and you can get back a list of your friends like this, where one of the user has installed your application (true):

  "id": "100002656xxxxxx"
  "installed": true, 
  "id": "100004366xxxxxx"