Tom Tom - 7 months ago 41
iOS Question

Facebook iOS SDK and swift: how get user's profile picture

i have integrated Facebook sdk in Xcode 6 (with swift).
During the login i request the public_profile permission:

FBSession.openActiveSessionWithReadPermissions(["public_profile"], allowLoginUI: true, completionHandler: {

So i request the user's information:

FBRequestConnection.startForMeWithCompletionHandler { (connection, user, error) -> Void in

Why the user object doesn't contain the profile picture? How can i get the user profile picture? It's not part of the public_profile?

I get the following information:

2015-01-25 01:25:18.858 Test[767:23804] {
"first_name" = xxx;
gender = xxx;
id = xxxxxxxxx;
"last_name" = xxxxxx;
link = "";
locale = "xxxxx";
name = "xxxxxxx xxxxxxx";
timezone = 1;
"updated_time" = "2013-12-21T18:45:29+0000";
verified = 1;

P.S: xxx for privacy


The profile picture is in fact public and you can simply by adding the user id to Facebook's designated profile picture url address, ex:

var userID = user["id"] as NSString     
var facebookProfileUrl = "\(userID)/picture?type=large"

This particular url address should return the "large" version of the user's profile picture, but several more photo options are available in the docs.