Listing Facebook friends who are Firebase app users

2,660 views
Skip to first unread message

Emile Bennett

unread,
Aug 28, 2015, 1:44:00 PM8/28/15
to Firebase Google Group
Hi guys,

My first post on here so be nice ;)

I've just started digging around with Firebase, and have been getting my head around the https://github.com/firebase/ios-location-example 

It all makes sense, but this example shows 'any' user of the app. I'd like to understand how to only show users that are my friends on Facebook. Seeing as I authenticate with Facebook in this example I figured it would be pretty trivial...but I am scratching my head.

As I say I am new to this, not iOS development in general, but certainly the social API side of things. Any help / guidance / examples you can give me would be great!

Cheers

Emile

Simeon Vincent

unread,
Aug 29, 2015, 7:32:50 PM8/29/15
to Firebase Google Group
I'm not super familiar with the FB APIs, but as I understand it you'll need to use their Graph API to retrieve a list of friends. https://developers.facebook.com/docs/graph-api/reference/v2.4/user/friends

To get this data, you'll first have to add the "user_friends" scope to your auth flow as described here: https://www.firebase.com/docs/web/guide/login/facebook.html#section-logging-in

Hopefully that's enough to get you on the right path :D

-Simeon

Remi Grumeau

unread,
Aug 30, 2015, 9:36:46 PM8/30/15
to Firebase Google Group
You can't access a user's friend list. Only a Facebook application can.
So the first step is to create a Facebook application.

Then, you can use the login dialog plugin and set your application ID in it.

When a user hit the button, it asks him to accept that your FB application can get his/her infos & friends list.
Lucky you, the friends list is part of the main scope, so you don't have to ask anything more.
Since latest API releases, friends list is force scoped to mutual friends using the app too (before that, you could list the entire list of user's friend...).

Sadly, this friends list will only gives you the full list of user's friends, as an array of objects (id, name, first_name, last_name, gender). Yup, that means if a friend signed-in not via Facebook login but a regular form, you're doomed...

Remi
Reply all
Reply to author
Forward
0 new messages