Documentation › Select Friends by Device
The Facebook SDK for iOS includes an FBFriendPickerViewController control object that makes it simple to add a friend selector to your app. The friend selector can filter the friends you display.
You may want to restrict the friends that display to show only those with specific devices. As an example, you may want to target friends that use platforms you support for a subsequent invite to use your app. This article guides you through how you can use a query for friend device data to filter the friends in the friend selector.
This document walks through the following topics:
Prerequisites
Sample Overview
Step 1: Set Up the Friend Selector and Query Device Data
Step 2: Filter the Friend Selector with Device Data
Troubleshooting
Additional Info
Prerequisites
The code for the starting point for this doc can be found on GitHub. If you haven't done so, clone the how-to samples for the Facebook SDK:
git clone https://github.com/fbsamples/ios-3.5-howtos.git
Then open the Xcode project under the FriendPickerDeviceFilterHowTo/Initial folder.
Sample Overview
The completed sample allows users to log in with Facebook and select friends with iOS devices. In this simple sample, we'll echo back the selected friends.
After the person logs in, a button is available that's used to show the friend selector. The friend selector is configured to display Done and Cancel buttons that dismiss the picker. The displayed friends are filtered to only include friends with iOS devices.
The friend selector displays with the FBFriendPickerViewController Facebook SDK object. After the object is initialized, call the loadData instance method to load and set up the initial friend selection. During the initialization step, the object is configured to request friend device data. During the display step, the FBFriendPickerDelegate protocol's friendPickerViewController:shouldIncludeUser: method is