iOS Facebook Friends View

iOS Facebook Friends View

Released 5 years ago , Last update 4 years ago

Facebook Friends View is a Control for displaying your Facebook Friends by their profile picture. This package includes full source code and a working demo.

If you want to develop an app using the Facebook Graph API, this framework and UIFacebookFriendsView UIView subclass will help you get there quickly and easily.

UIFacebookFriendsView is a UIView subclass for creating a selectable view showing all of your Facebook Friends by their profile image. Use for user interface or hide and use as controller for Facebook functionality. Automatically chooses larger profile pictures provided by Facebook based on the size or style you use. The view can be any size and the profile images can be of defined styles or your specified sizes. The profile images flow in the created view and each friend is select-able.

Includes automatic and manual log-in to Facebook. As needed, user is prompted for Facebook credentials and authorization details.

Get any of your Facebook friend's wall status for any friend and display in a view or dump to the console. Demo shows how to acquire and display friends profile photo, wall status, online status, popup menu, customized popup menu, select to show status, display wall status for selected friend and much more.

Search your Facebook friends details for specific text or search specific friends details such as username, first name, last name, locale, gender and name.

Some uses:

  1. Great starting point for creating an app using the Facebook Graph API (Facebook SDK).
  2. Easily add Facebook functionality to your app as view contains everything to use Facebook. Use automatic login or manually log in and out if you desire. UIFacebookFriendsView automatically keeps track of your session and logins and will prompt for login if session expires.
  3. Add a friend view to your app from which to show friend's wall status, go to their Facebook home page, post to their home page or whatever action you desire. Can add custom actions also.
  4. Create a friends right or left side bar for selecting Facebook friends to start some desired action or when a friend is selected show details left hand panel.
  5. Use a friend view to show the online status of all your friends.
  6. Any app that needs to show your Facebook friends can leverage this view has it is fully customizable and you control what is done when receiving callbacks to your app.
  7. Get the live wall status of any or all of your friends.
  8. Get the live online status of any or all of your friends.

iOS Support

This project supports iOS 7, iOS 8, iOS 9 and iOS 10.

5.0
  • 5 1
  • 4 0
  • 3 0
  • 2 0
  • 1 0
1 Reviews Read Reviews

Pricing

14 day 14-day money-back guarantee

$9.99

Single App

  • Perpetual license

  • 1 application

  • Can distribute binary products only

  • Commercial use

  • 1 month support

$19.99

Developer

  • Perpetual license

  • Unlimited projects

  • Can distribute code and binary products

  • Commercial use

  • 12 months support

Supported OS and SDK Versions

  • Supported build target - iOS 6.0, iOS7, iOS8, iOS 9 and iOS 10 / Mac OS 10.7 (Xcode 4.3.1, Apple LLVM compiler 3.1)
  • Earliest supported deployment target - iOS 6.0 / Mac OS 10.6
  • Earliest compatible deployment target - iOS 6.0 / Mac OS 10.6

NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this OS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.

Installation

To install UIFacebookFriendsView into your app, create a UIFacebookFriendsView folder in your project then drag the files in the UIFacebookFriendsViewDemo project UIFacebookFriendsView folder to the created folder. Make sure that you indicate to copy the files into your project. Also make sure that the Target Membership is checked for all .m source files and non .h files.

Usage

// see Demo Example in Examples/Demo folder for full source code

// change this id to your Facebook appId    
// see http://developer.facebook.com/apps
// you can use this "Friends app" id or your own
NSString * facebookAppId = @"234870326587537";    

// Automatic login, prompts if not logged in...  
UIFacebookFriendsView *  facebookFriendsView = [[UIFacebookFriendsView alloc] initWithFrame:CGRectMake(0, 0,  500, 300) delegate:self facebookAppId:facebookAppId pictureStyle:PictureStyleNormal];
[facebookFriendsView setVerbose:verbose];
[self.view addSubview:facebookFriendsView];

// can get Facebook object, if desire
Facebook * facebook = [facebookFriendsView getFacebook];
NSLog(@"facebook is %@", facebook);

NSMutableArray * friendNames = [facebookFriendsView getFriendNames];   // get friend names

NSMutableArray * friendOnlineNames = [facebookFriendsView getFriendOnlineNames];  // get online friend names

NSMutableArray * friendNames = [facebookFriendsView getFriendIds];     // get Friends Facebook ids

NSMutableArray * friendViews = [facebookFriendsView getFriendViews];   // get FriendsViews (shown views with friends profile images)

NSMutableArray * friendViewObjects = [facebookFriendsView getFriendObjects];   

//---------------------------------------------------------------

//  callback example for friend clicked in UIFacebookFriendsView

- (void)ffFriendClicked:(FriendView *)friendView parent:(UIView *)parent {

UIFacebookFriendsView * _parentView = (UIFacebookFriendsView *)parent;

// methods to get details for a specific friend.
//
// get the FriendObject for the friend view that use clicked.
// The FriendObject hold friends basic details.   For advances
// details such as wall status a separate method is provided to
// minimize initial processing tim
FriendObject * friendObject = friendView.friendObject;

// get additional details for the friend...
FriendObject * userInfo = [facebookFriendsView getUserInfo:friendView];

if (userInfo != nil) {
    friendObject._username = userInfo._username;
    friendObject._firstName = userInfo._firstName;
    friendObject._lastName = userInfo._lastName;
    friendObject._gender = userInfo._gender;
    friendObject._locale = userInfo._locale;
}

int friendCount = [facebookFriendsView getFriendCount];

// four arrays holding Facebook names, Facebook ids, FriendViews for all
// your friends and friendObjects for all your friends...
NSMutableArray * names = [facebookFriendsView getFriendNames];
NSMutableArray * ids = [facebookFriendsView getFriendIds];
NSMutableArray * friendViews = [facebookFriendsView getFriendViews];
NSMutableArray * friendObjects = [facebookFriendsView getFriendObjects];

NSLog(@"---------------------------------------------------");
NSLog(@"You selected your friend %@...", friendObject._name);
NSLog(@"You have %d friends [%d names, %d ids, %d friendViews, %d friendObjects]", friendCount, names.count, ids.count, friendViews.count, friendObjects.count);

NSLog(@"Your friends details:");    
NSLog(@"  - Facebook username is %@", friendObject._username);
BOOL online = [friendView isOnline];
if (online)
    NSLog(@"  - User is online.");
else
    NSLog(@"  - User is offline.");
NSLog(@"  - Facebook Id is %@", friendObject._id);
NSLog(@"  - Profile image url is %@", friendObject._imageUrl);

NSString * smallPictureUrl = [facebookFriendsView getPictureSmallUrl:friendView];
NSLog(@"  - Profile small image url is %@", smallPictureUrl);
NSString * normalPictureUrl = [facebookFriendsView getPictureNormalUrl:friendView];
NSLog(@"  - Profile normal image url is %@", normalPictureUrl);
NSString * largePictureUrl = [facebookFriendsView getPictureLargeUrl:friendView];
NSLog(@"  - Profile large image url is %@", largePictureUrl);

NSLog(@"  - Home page link is %@", friendObject._link);
NSLog(@"  - First name is %@", friendObject._firstName);
NSLog(@"  - Last name is %@", friendObject._lastName);
NSLog(@"  - Gender is %@", friendObject._gender);
NSLog(@"  - Locale is %@", friendObject._locale);
NSLog(@"---------------------------------------------------");

// methods to acquire details for the logged in Facebook user...
NSString * loggedInUserFacebookName = [facebookFriendsView getLoggedInUserFacebookName];
NSString * loggedInUserAppId = [facebookFriendsView getLoggedInUserAppId];
NSString * loggedInUserFacebooklocation = [facebookFriendsView getLoggedInUserFacebookLocation];
NSString * loggedInUseFacebookLink = [facebookFriendsView getLoggedInUserFacebookLink];
NSString * loggedInUserFacebookId = [facebookFriendsView getLoggedInUserFacebookId];

NSLog(@"---------------------------------------------------");
NSLog(@"Logged in user details:");
NSLog(@"   - Name is %@", loggedInUserFacebookName);
NSLog(@"   - Facebook AppId is %@", loggedInUserAppId);
NSLog(@"   - Location is %@", loggedInUserFacebooklocation);
NSLog(@"   - Home page link is %@", loggedInUseFacebookLink);
NSLog(@"   - Facebook id is %@", loggedInUserFacebookId);
NSLog(@"---------------------------------------------------");
}

Example Project Demo

The demo example in the Examples/Demo folder demonstrates how you might implement using UIFacebookFriendsView.

When run, the app displays all of your Facebook friends using their Facebook profile image.

The example is for iOS.

Constructors

// create UIFacebookFriendsView...
//
//
// This constructor is used normally and uses nice defaults
//
// frame specific the location and size the view in your parent view
// delegate gets callbacks, facebookAppId is your Facebook appId (see developers.facebook.com),
// pictureStyle is the style for the Facebook profile pictures displayed. if you want better control, then use the 2nd constructor and specify pixel size.
//    PictureStyleSmall
//    PictureStyleNormal
//    PictureStyleFullsize
//    PictureStyleLarge
//
- (id)initWithFrame:(CGRect)frame delegate:(id)delegate facebookAppId:(NSString *)_facebookAppId pictureStyle:(PictureStyle)_pictureStyle;

// This constructor is for total control
//
// frame specific the location and size the view in your parent view
// delegate gets callbacks, facebookAppId is your Facebook appId (see developers.facebook.com),
// pictureSize is the size for the Facebook profile pictures displayed (-1 uses default of 50 pixels),
// includeOnlineStatus indicates hether to include the online indicator (green dot)
// cornerRadius for adding corners to the view (0 or -1 denotes no corners)
//
- (id)initWithFrame:(CGRect)frame delegate:(id)delegate facebookAppId:(NSString *)_facebookAppId pictureSize:(int)_pictureSize includeOnlineStatus:(BOOL)_includeOnlineStatus autoLogin:(BOOL)_autoLogin cornerRadius:(int)_cornerRadius;

Methods

// the view automatically does a login and prompts you, if necessary.
// However, you can manually logout then login if you like later.
- (void)loginFacebook;
- (void)logoutFacebook;

// checks to see if the Facebook session is still valid.
// TRUE - is valid, FALSE is not valid
- (BOOL)checkFacebookSession;

// see if logged in or not
// TRUE - logged in, FALSE - not logged in
- (BOOL)isLoggedIn;

// checks to see if Facebook session has expired.
// like checkFacebookSesseion except has verbose debugging flag
- (BOOL)hasFacebookSessionExpired:(BOOL)_verbose;

- (int)getFriendCount;                // get the number of friends found
- (NSMutableArray *)getFriendNames;   // get the array of friend names
- (NSMutableArray *)getFriendOnlineNames;  // get the array of online friend names
- (NSMutableArray *)getFriendIds;     // get the array o Friends Facebook ids
- (NSMutableArray *)getFriendViews;   // get an array of Friends FriendsViews (shown views with friends profile images)
- (NSMutableArray *)getFriendObjects; // get an array o Friends FriendObject (friend detail for FriendsViews shown.

- (NSString *)getLoggedInUserAppId;             // get the the logged in users AppId
- (NSString *)getLoggedInUserFacebookName;      // get the logged in user's Facebook name
- (NSString *)getLoggedInUserFacebookLocation;  // get the logged in user's Faceboo location
- (NSString *)getLoggedInUserFacebookLink;      // get the logged in user's Facebook homepage link
- (NSString *)getLoggedInUserFacebookId;        // get the logged in user's Facebook id

- (FriendObject *)getUserInfo:(FriendView *)friendView;  // get additional details such as gender and locale
- (FriendObject *)getUserInfoById:(NSString *)_id;  // get additional details such as gender and locale

// Returns an array of the friends wall posts or nil or error
// (newer entries come first)
//
- (NSMutableArray *)getUserWallStatus:(FriendView *)friendView;  // get the wall status for a friend
- (NSMutableArray *)getUserWallStatusById:(NSString *)_id;  // get the wall status for a friend

// get the user status for a user
//
// Returns an array of wall posts or nil
- (NSArray *)getUserStatus:(FriendView *)friendView;
- (NSArray *)getUserStatusById:(NSString *)_id;

// get the user feed status for a user
//
// Returns an array of wall posts or nil
- (NSArray *)getUserStatusMessage:(FriendView *)friendView;
- (NSArray *)getUserStatusMessageById:(NSString *)_id;

// Return TRUE if online, FALSE if offline
- (BOOL)isFriendOnline:(FriendView *)_friendView;   // get the online status for a friend

// show a popup menu for the selected user.
// Should  be called in ffFriendClicked callback usually.
// refer to the FacebookFriendsViewDelegate protocol below for delegate callbacks
// Note: ffCustomAction is only called when your custom menu item is added (see showCustomPopupMenu below)
//
- (void)showPopupMenu:(FriendView *)_friendView parent:(UIView *)_parent;

// show a popup menu for the selected user.
// Should  be called in ffFriendClicked callback usually.
// refer to the FacebookFriendsViewDelegate protocol below for delegate callbacks
// for customPopupMenu, ffCustomAction is only called when your custom menu item is clicked
// (Note: 30x30 png for custom menu image if best)
//
- (void)showCustomPopupMenu:(FriendView *)_friendView parent:(UIView *)_parent customImage:(UIImage *)_customImage;

// Show the wall status for the friend
- (void)showWallStatus:(FriendView *)_friendView parent:(UIViewController *)_parent;

// scroll to the specified Friends FriendView...
- (void)scrollToFriend:(FriendView *)_friendView;

// Search friend name, first name, last name, and username for the text
//
// Options:
//     FriendSearchOptionsAll - search name, first name, last name and user name
//     FriendSearchOptionsName - search just name
//     FriendSearchOptionsFirstName - search just first name
//     FriendSearchOptionsLastName - search just last name
//     FriendSearchOptionsUserName - search just user name
//     FriendSearchOptionsGender - search just gender
//     FriendSearchOptionsLocale = search just locale
//
// searchAll - if TRUE, searches all and results ALL matches otherwise
//             first match is returned
//
// returns an array of FriendView objects or nil if not matches found
- (NSMutableArray *)searchForText:(NSString *)_text options:(FriendSearchOptions)_options searchAll:(BOOL)_searchall;

// Search friend name, first name, last name, and username for the text
//
// Options:
//     FriendSearchOptionsAll - search name, first name, last name and user name
//     FriendSearchOptionsName - search just name
//     FriendSearchOptionsFirstName - search just first name
//     FriendSearchOptionsLastName - search just last name
//     FriendSearchOptionsUserName - search just user name
//     FriendSearchOptionsGender - search just gender
//     FriendSearchOptionsLocale = search just locale
//
// searchAll - if TRUE, searches all and results ALL matches otherwise
//             first match is returned
//
// returns an array of FriendView objects or nil if no matches found
- (NSMutableArray *)searchAllForText:(NSString *)_text searchAll:(BOOL)_searchAll;

Callbacks

- (void)ffLog:(NSString *)msg {

if (verbose)
    NSLog(@"%@", msg);
}

- (void)ffFacebookDidLogin:(NSString *)_facebookName expirationDate:(NSString *)_expirationDate {

if (_facebookName != nil)
    NSLog(@"logged into Facebook as %@  Expiration date is %@", _facebookName, _expirationDate);
else
    NSLog(@"logged into Facebook...");
}

- (void)ffFacebookAlreadyLoggedIn:(NSString *)_facebookName expirationDate:(NSString *)_expirationDate {

if (_facebookName != nil)
    NSLog(@"already logged into Facebook as %@!  Expiration date is %@", _facebookName, _expirationDate);
else
    NSLog(@"already logged into Facebook!");
}

- (void)ffFacebookDidNotLogin:(NSString *)_facebookName cancelled:(BOOL)_cancelled {

if (_facebookName != nil)
    NSLog(@"did not log into Facebook as %@!", _facebookName);
else
    NSLog(@"did not log into Facebook!");
}

- (void)ffFacebookSessionExpired:(NSString *)_facebookName {

if (_facebookName != nil)
    NSLog(@"%@ Facebook session expired!", _facebookName);
else
    NSLog(@"Your Facebook session expired!");

NSString * msg = nil;

if (_facebookName != nil)
    msg = [NSString stringWithFormat:@"%@ Facebook session has expired!", _facebookName];
else
    msg = @"Your Facebook session has expired!";

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Facebook Notice" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles:     @"OK", nil];
[alert show];
}

- (void)ffFacebookDidLogout:(NSString *)_facebookName {

if (_facebookName != nil)
    NSLog(@"%@ logged out of Facebook!", _facebookName);
else
    NSLog(@"logged out of Facebook!");
}

// Callback received when user clicks on a Facebook friends picture.
//
// At this point you can call various FacebookFriendsView methods to acquire details for the friend,
// show a popup allowing the user to select to do a post or goto the friends home page, getting friends
// wall status, search and more.   If the popup is shown (see below example) you will receive another callback
// when the user clicks on the post or goto Facebook home page action icon.
//
- (void)ffFriendClicked:(FriendView *)friendView parent:(UIView *)parent {

UIFacebookFriendsView * _parentView = (UIFacebookFriendsView *)parent;

// methods to get details for a specific friend.
//
// get the FriendObject for the friend view that use clicked.
// The FriendObject hold friends basic details.   For advances
// details such as wall status a separate method is provided to
// minimize initial processing tim
FriendObject * friendObject = friendView.friendObject;

// get additional details for the friend...
FriendObject * userInfo = [facebookFriendsView getUserInfo:friendView];

if (userInfo != nil) {
    friendObject._username = userInfo._username;
    friendObject._firstName = userInfo._firstName;
    friendObject._lastName = userInfo._lastName;
    friendObject._gender = userInfo._gender;
    friendObject._locale = userInfo._locale;
}

int friendCount = [facebookFriendsView getFriendCount];

// four arrays holding Facebook names, Facebook ids, FriendViews for all
// your friends and friendObjects for all your friends...
NSMutableArray * names = [facebookFriendsView getFriendNames];
NSMutableArray * ids = [facebookFriendsView getFriendIds];
NSMutableArray * friendViews = [facebookFriendsView getFriendViews];
NSMutableArray * friendObjects = [facebookFriendsView getFriendObjects];

NSLog(@"---------------------------------------------------");
NSLog(@"You selected your friend %@...", friendObject._name);
NSLog(@"You have %d friends [%d names, %d ids, %d friendViews, %d friendObjects]", friendCount, names.count, ids.count, friendViews.count, friendObjects.count);

NSLog(@"Your friends details:");    
NSLog(@"  - Facebook username is %@", friendObject._username);
BOOL online = [friendView isOnline];
if (online)
    NSLog(@"  - User is online.");
else
    NSLog(@"  - User is offline.");
NSLog(@"  - Facebook Id is %@", friendObject._id);
NSLog(@"  - Profile image url is %@", friendObject._imageUrl);

NSString * smallPictureUrl = [facebookFriendsView getPictureSmallUrl:friendView];
NSLog(@"  - Profile small image url is %@", smallPictureUrl);
NSString * normalPictureUrl = [facebookFriendsView getPictureNormalUrl:friendView];
NSLog(@"  - Profile normal image url is %@", normalPictureUrl);
NSString * largePictureUrl = [facebookFriendsView getPictureLargeUrl:friendView];
NSLog(@"  - Profile large image url is %@", largePictureUrl);

NSLog(@"  - Home page link is %@", friendObject._link);
NSLog(@"  - First name is %@", friendObject._firstName);
NSLog(@"  - Last name is %@", friendObject._lastName);
NSLog(@"  - Gender is %@", friendObject._gender);
NSLog(@"  - Locale is %@", friendObject._locale);
NSLog(@"---------------------------------------------------");

// methods to acquire details for the logged in Facebook user...
NSString * loggedInUserFacebookName = [facebookFriendsView getLoggedInUserFacebookName];
NSString * loggedInUserAppId = [facebookFriendsView getLoggedInUserAppId];
NSString * loggedInUserFacebooklocation = [facebookFriendsView getLoggedInUserFacebookLocation];
NSString * loggedInUseFacebookLink = [facebookFriendsView getLoggedInUserFacebookLink];
NSString * loggedInUserFacebookId = [facebookFriendsView getLoggedInUserFacebookId];

NSLog(@"---------------------------------------------------");
NSLog(@"Logged in user details:");
NSLog(@"   - Name is %@", loggedInUserFacebookName);
NSLog(@"   - Facebook AppId is %@", loggedInUserAppId);
NSLog(@"   - Location is %@", loggedInUserFacebooklocation);
NSLog(@"   - Home page link is %@", loggedInUseFacebookLink);
NSLog(@"   - Facebook id is %@", loggedInUserFacebookId);
NSLog(@"---------------------------------------------------");
}


// Callback called when user clicks on the popup menu Post to Facebook action icon...
- (void)ffPostToFacebook:(FriendView *)friendView parent:(UIView *)parent  {

UIFacebookFriendsView * _parentView = (UIFacebookFriendsView *)parent;
FriendObject * friendObject = friendView.friendObject;
NSLog(@"Post request for your friend %@...", friendObject._name);

[friendView postToFacebookPrompt];
}


// Callback called when user clicks on the popup menu Show Facebook Status action icon...
- (void)ffShowFacebookStatus:(FriendView *)friendView parent:(UIView *)parent {

UIFacebookFriendsView * _parentView = (UIFacebookFriendsView *)parent;
FriendObject * friendObject = friendView.friendObject;
NSLog(@"Show Facebook status for your friend %@...", friendObject._name);

// Uncomment for local show wall status example that dumps out 
// wall status to the console
//[self showWallStatus:friendView parent:parent];

// Or use method to show wall status for a friend in a window
[_parentView showWallStatus:friendView parent:self];
}

// Callback called when user clicks on the popup menu Goto Facebook action icon...
- (void)ffGoToFacebook:(FriendView *)friendView parent:(UIView *)parent {

UIFacebookFriendsView * _parentView = (UIFacebookFriendsView *)parent;
FriendObject * friendObject = friendView.friendObject;
NSLog(@"Go to Facebook request for your friend %@...", friendObject._name);

[friendView goToFacebookHomePage:self];
}

// Callback called when user the Custom Action action icon...
- (void)ffCustomAction:(FriendView *)friendView parent:(UIView *)parent  {

UIFacebookFriendsView * _parentView = (UIFacebookFriendsView *)parent;
FriendObject * friendObject = friendView.friendObject;
NSLog(@"Your Custom Action request (map) for your friend %@...", friendObject._name);
}

// Callback called when have acquired friends
- (void)ffFacebookGotFriends:(NSString *)_facebookName parent:(UIView *)parent {

}
3 licenses, starting from From » $9.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
  • VV vincent villaruel 2 years ago
    i have a 3rd party iphone tool that creates all the forms and views and uses javascript to interface with obj C code. Can i make this tool work to login to facebook , share, like and post images etc... ? (ie in JS: var isLogin = Facebook.isLogin ; or var posted = Facebook.post(name,title,caption,urlLink,ImgLink) ?)
  • SP Suhas Patil 3 years ago
    does this application will after April'15 as Facebook changing its policy to fetch all friends, instead right now they are giving the friends list who used your application.