Question

In my android application a user that is logged in using facebook should see his friends that also use my application (and of course logged in using their facebook account)

The very first thing that I thought is holding a user table on my own, and for every friend of a user check whether that user is in my user list or not, but this doesn't seem so efficient to me.

Is there any better way to achieve my requirement?

Was it helpful?

Solution

Yes, you can know who of your friends installed and logged with your app without managing this information by yourself.

User graph api entity has installed property. From doc:

Is the app making the request installed

You will get true for all users that have your app installed, means they logged once with your app.

To get this field you will need to put it as GET parameter. For example:

me/friends?fields=id,first_name,installed


By the way, you can use this library with example or use the source code to have this value in a very simple way: https://github.com/sromku/android-simple-facebook

OnFriendsRequestListener onFriendsRequestListener = new OnFriendsRequestListener() {
    @Override
    public void onComplete(List<Profile> friends) {
        // iterate here through profiles 
        for (Profile profile : friends) {
            boolean installed = profile.getInstalled();
        }
    }
}

// prepare the properties that you need
Properties properties = new Properties.Builder()
        .add(Properties.ID)
        .add(Properties.FIRST_NAME)
        .add(Properties.INSTALLED)
        .build();

mSimpleFacebook.getFriends(properties, onFriendsRequestListener);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top