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?
Asked
Active
Viewed 1,741 times
1
-
it is possible of course =) for example `draw something` does exactly that. i cannot tell you how, but i know that it is possible =) ill mark this thread, hoping to read a good answer on how as well. – Sebastian Flückiger Apr 06 '12 at 11:59
4 Answers
4
Yes, it's possible.
- You will need to maintain your own database of who has installed the application.
- When a user installs the application, they connect to Facebook through one of the APIs, get their userID, and submit it to your database with the flag that the user installed the application.
- You then ask Facebook through one of its APIs for that user's list of friends' IDs, and then ask your database if any of those IDs have the associated flag set.

Peter Mortensen
- 30,738
- 21
- 105
- 131

lmirosevic
- 15,787
- 13
- 70
- 116
-
1This is really slow for applications that don't store a local database of users who have installed the application (this can eventually be unreasonably large), and in any case it's inaccurate when a new user installs the application and the local database doesn't record the change. The best method is to ask the graph API for the "installed" property — http://stackoverflow.com/a/12280544/267814 – Arseniy Banayev Jan 07 '13 at 20:21
4
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_ ];

Peter Mortensen
- 30,738
- 21
- 105
- 131

Daniel Huang
- 113
- 1
- 7
-
This is great, thanks. Here's the raw FQL---> Select name, uid, pic_small from user where is_app_user = 1 and uid in (select uid2 from friend where uid1 = me()) order by concat(first_name,last_name) asc – Joe Jun 11 '12 at 15:44
0
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;
}
}
}
}
}];

BootMaker
- 1,639
- 1
- 22
- 24
0
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)

wheeliebin
- 716
- 1
- 6
- 20