Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Facebook SDK 3.0

This article is co-authored by Pallak Grewal and Rohan Bali.

Facebook iOS SDK 3.0 makes it easier for developers to integrate Facebook into their mobile applications. This new release comes with a host of major updates, from FBSession which lets an app manage the user’s session with ease to a bunch of smaller features like making it easier to create basic API calls to the Facebook OpenGraph. This version of the SDK also introduces blocks for a cleaner handling of various calls to Facebook.

The main new SDK Features include:

1. Better Session Management

The FBSession class makes it easy to manage user sessions. It provides a single manager that controls, refreshes and stores the user’s token. It also provides a clean user login/logout interface.

FBSession *sessionOne = [[FBSession alloc] initWithPermissions:permissions];

[sessionTwo openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {

An app can also now easily check the status of the FBSession, i.e. if it is open, closed or currently being authenticated. FBSessions gives the app more flexibility than previously possible. An app can now maintain multiple FBSessions while maintaining an open active Facebook session.

2. Easy to Implement and Ready to Use Facebook User Interface Components

There are four new Facebook components that now come pre-built with the SDK:

a) FBLoginView – This View provides an icon interface which makes it easy to manage logins and logouts. The FBLoginView informs the app about its status using the FBLoginViewDelegate.

NSArray *permissions = [NSArray arrayWithObjects:

FBLoginView *loginview = [[FBLoginView alloc] initWithPermissions:permissions]; = FBLoginViewStyleSquareLarge;
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];

On login the FBLoginView sets the activeSession in FBSession and returns the logged-in user to the app. The FBLoginView has the limitation that it can not request any of the user’s fields (eg. picture) apart from the default ones. Therefore the app would need to make additional calls to retrieve the additional fields.

b) FBProfilePictureView  – When initialized with the user’s Facebook id, this view loads the user’s profile picture.

FBProfilePictureView *profileImage = [[FBProfilePictureView alloc] pictureCropping:FBProfilePictureCroppingOriginal];
//Set profileImage frame as needed
[self.view addSubview:friendImage];

Although the FBProfilePictureView is convenient to use, its functionality is very limited. The FBProfilePictureView is initialized using a person’s Facebook id. It then makes a call to retrieve the person’s Facebook profile image. This process is slow, especially when displaying profile pictures for yourself or your friend as the profile picture URL is usually already available to you beforehand.

The FBProfilePictureView is also tricky to align if the cropping style is set to FBProfilePictureCroppingOriginal.

c) FBPlacePickerViewController – This view controller allows the app to query specific places near the user. These places are displayed in a Table View from which the user may select a place.

FBPlacePickerViewController *placePickerController = [[FBPlacePickerViewController alloc] init];
placePickerController.delegate = self;
placePickerController.title = @"Select Your Place";
placePickerController.locationCoordinate = locationManager_.location.coordinate;
placePickerController.resultsLimit = 100;
placePickerController.searchText = @”Grocery”;
[placePickerController loadData];
[self.navigationController pushViewController:placePickerController animated:YES];

Although the FBPlacePickerView is easy to implement, it is not very customizable and doesn’t support features such as multiple place selection.

d) FBFriendPickerViewController – This view controller allows the app to access the user’s friends and then displays them in an alphabetically indexed Table View. The user can then choose his friends from that Table View.

FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc] init];

friendPicker.fieldsForRequest = [[NSSet alloc] initWithObjects:@"birthday", @"hometown", nil];

friendPicker.delegate = self;
[friendPicker loadData];
[self.navigationController pushViewController:friendPicker animated:YES];

Once again the FBFriendsPickerViewController is not very customizable, and lacks a search bar to search through your friends.

3. Modern Objective-C language features support

This SDK includes support for Automatic Reference Counting (ARC). It also implements blocks, which make calls to Facebook both easier to manage and cleaner in code. Facebook has also updated a few language features – they now include idiomatic API naming and KVO – these, according to Facebook will allow developers to transition seamlessly between the Facebook SDK and the Apple’s iOS environment.

In our experience, we found that language updates to the Facebook objects did facilitate writing cleaner code. The addition of the FBRequestConnection class which manages connections and the FBRequest class that defines a request has made Facebook calls easier to understand and much more flexible than they used to be. FBRequest also pre-defines commonly used functions such as requestForMe and requestForMyFriends, which thoughtful touch, making Facebook integration even more straightforward.

4. Improved Facebook APIs support

Facebook has enabled batching for SDK requests to improve latency for Facebook API calls, thus making API requests faster.

Support for strongly typed Objective-C types for graph actions and objects makes programming against the social graph easier and more concise. According to Facebook, these features, combined with the action publishing API, make it easier to publish Open Graph actions to people’s timelines.

Along with the release of the new SDK Facebook has also launched its iOS Dev Center. The Dev Center provides a central place for iOS developers to learn about Facebook iOS integration. The Dev Center contains educational SDK resources including tutorials, reference documents, and links to the Facebook StackOverflow and facebook SDK bugs pages.

iOS 6 Native Integration

With the introduction of iOS 6.0 at the end of the year, Facebook will be integrated throughout iOS devices. So, once you sign in, you can easily post from native apps like the camera, the gallery, Maps and the game center or any other app that uses Single Sign-on. Facebook login within apps will now be handled by the native iOS Facebook framework. According to Facebook, the SDK for iOS will automatically choose the best option when you attempt to use Facebook login. If you previously gave your app permissions, the SDK will immediately return an OAuth2 access token back to your app, possibly without even showing you a prompt.

With Facebook integrated right into your iOS device, you will also have the option to merge your Facebook friends into Contacts. The Contacts app will read information off your friends’ profiles and automatically update any changes made by your friends. The Facebook calendar can also be synchronized into the native calendar app, providing reminders for birthdays and Facebook events.

Facebook still does not have an API call for a custom Like button in apps. However, they have added Like buttons to the App Store and to iTunes, so that you can share without leaving these apps. You can also update your Facebook status using Siri or the notification center.

With these new updates, Facebook is making itself more integrated with iOS devices than ever before. These new updates make it extremely easy to implement Facebook into apps and makes Facebook an integral part of the iOS experience.