1
I would like to know how I show a list with my facebook friends using the facebook SDK for IOS and with Swift. I’ve already done the installation and I’m already logging in on facebook. I’m just not able to show my friends list.
1
I would like to know how I show a list with my facebook friends using the facebook SDK for IOS and with Swift. I’ve already done the installation and I’m already logging in on facebook. I’m just not able to show my friends list.
0
From the Graph API 2.0, the full list of friends is no longer allowed by default in authentication and only returns friends who have authorized, ie those who also own your application.
So, first of all you need to ask permission from the user as soon as you perform the authentication. Just the proper key for such:
user_friends
With this permission accepted by the user, you can then make the request:
var friendsRequest : FBRequest = FBRequest.requestForMyFriends()
friendsRequest.startWithCompletionHandler{(connection:FBRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
var resultdict = result as NSDictionary
var friends = resultdict.objectForKey("data") as NSArray
}
With this, you will possess in vector friends
the list of friends, and then just assemble your list of friends.
In this response from Soen has some alternatives to search for all friends, regardless of whether the friend owns or not their application, which is based on using the endpoints /me/taggable_friends
and /me/invitable_friends
of API. But since I don’t know your app, I don’t know if it fits these alternatives.
Browser other questions tagged ios facebook swift
You are not signed in. Login or sign up in order to post.
You’re already logging in to the application or the question involves the whole process (which is a bit long), including installing the SDK?
– Paulo Rodrigues
I’ve already done the installation and I’m already logging in on facebook. I’m just not able to show my friends list.
– Filipe Amaral Neis
I voted to reopen, but maybe you can put these details in the question itself, enough edit, so you might understand that it’s not too wide.
– Paulo Rodrigues
Adjustments made
– Filipe Amaral Neis
If you already have some code that you tried to make work but failed is always valid too.
– Otávio
I don’t have Otávio, I saw some examples and OC but I couldn’t do anything like that in Swift.
– Filipe Amaral Neis