Adding “Invite Friend” to an iOS app


If you’re an iPhone user, you must be glad that there are apps for just about anything. In fact, as of this writing, Apple’s App Store website boasts that it now has more than 500,000 apps. Impressive.

If you’re an iPhone app developer, it’s a different story. You must be scratching your head figuring out how to get your app noticed. One of the easiest ways is to tap into the Facebook friends of your app’s users. The idea is to let your users send to their Facebook friends an invitation to download your app.

I’ve quickly written an app that demonstrates how this can be done. You’ll need Facebook SDK for iOS. The steps are:
– Log user in to his/her Facebook account using Single Sign On.
– Display list of user’s Facebook friends.
– Once a friend is selected, display the standard Facebook “apprequests” dialog with custom message. Here’s how it looks:

The code that makes this happens is  fairly straight forward. Facebook SDK for iOS provides a convenient method, dialog, to display different type of standard Facebook dialogs. For more info, check this documentation out.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   NSDictionary *friend = [_friends objectAtIndex:indexPath.row];
   NSString *to = [friend objectForKey:@"id"];
   NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
          @"Check this app out...", @"message",
          to, @"to", nil];
   [self.facebook dialog:@"apprequests" andParams:params andDelegate:nil];

You can find the source code to this project here. Enjoy.

Leave a Reply

Your email address will not be published. Required fields are marked