Reputation: 21808
Is it possible to implement the following? I want to create an iOS application which allows the user to see all their Facebook friends who already have this application in their Facebook list. Is it achievable via Facebook Connect or Graph API or maybe something else?
Upvotes: 1
Views: 1747
Reputation: 735
Use Facebook login and then ask for the user's friends. You will only get those that have the requesting app installed (it used to return all friends with an 'installed' flag)
Upvotes: 0
Reputation: 1647
Yes you can do it with the new Facebook SDK 3.5 and greater (2013 June) using GraphAPI. You can use the deviceFilteredFriends mutable array later as you like...
// The Array for the filtered friends
NSMutableArray *installedFilteredFriends = [[NSMutableArray alloc] init];
// Request the list of friends of the logged in user (me)
[[FBRequest requestForGraphPath:@"me/friends?fields=installed"]
startWithCompletionHandler:
^(FBRequestConnection *connection,
NSDictionary *result,
NSError *error) {
// If we get a result with no errors...
if (!error && result)
{
// here is the result in a dictionary under a key "data"
NSArray *allFriendsResultData = [result objectForKey:@"data"];
if ([allFriendsResultData count] > 0)
{
// Loop through the friends
for (NSDictionary *friendObject in allFriendsResultData) {
// Check if installed data available
if ([friendObject objectForKey:@"installed"]) {
[installedFilteredFriends addObject: [friendObject objectForKey:@"id"]];
break;
}
}
}
}
}];
Upvotes: 0
Reputation: 113
If you have followed the Facebook tutorial iOS Tutorial.
You should have access to a "facebook" object in your AppDelegate.m
file. That "facebook" object will already have been registered with your specific application id.
You can then use it to query for the current user's friends who have already installed the application.
Here is the Facebook query to retrieve friend data:
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", _replace_this_with_the_fb_id_of_the_current_user_ ];
Upvotes: 4
Reputation: 16307
Yes, it's possible.
Upvotes: 4