I am using the code bellow to get the list of all of users friends and check how many of them have installed the app so i can show their scores, and unlock some content for the user.
I can't find solid info about the field installed which seams to be perfect for this case.(If it specifies the user has installed the app which made the request :) )
[FBRequestConnection startWithGraphPath:@"me/friends"
parameters: @{ @"fields" : @"id,installed"}
HTTPMethod:nil
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (!error) {
// Get the result
NSArray *resultData = result[@"data"];
// Check we have data
if ([resultData count] > 0) {
// Loop through the friends returned
for (NSDictionary *friendObject in resultData) {
// Check if devices info available
if (friendObject[@"installed"]) {
//Do some work if user has installed my game
}
}
}
}
}];
-(void)FBFriendList
{
if (!FBSession.activeSession.isOpen)
{
// if the session is closed, then we open it here, and establish a handler for state changes
[FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES completionHandler:^(FBSession *session,FBSessionState state, NSError *error)
{
if (error)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else if(session.isOpen)
{
[self FB_Common_Friend];
}
}];
return;
}
}
-(void)FB_Common_Friend
{
FBRequest *request = [FBRequest requestWithGraphPath:@"me/friends" parameters:@{@"fields":@"name,installed,first_name,picture"} HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
NSLog(@"%@",result);
int count = 0;
NSMutableArray *frnd_arr = [result objectForKey:@"data"];
for (int i = 0; i < [frnd_arr count]; i++)
{
if([[[frnd_arr objectAtIndex:i] objectForKey:@"installed"] boolValue])
{
count++;
}
}
app.fb_frnd_count = count;
}];
}