How to invite friends to my application via facebook iOS SDK and Graph API
It's simple you can just write the below code for personalised message and also you can easily select the friend's to whom the request should be sent, it's an straight forward and powerful method.
[FBWebDialogs presentRequestsDialogModallyWithSession:nil message:NSLocalizedString(@"FBinviteMessage", nil) title:nil parameters:nil handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {}];
Just add this six line of code to your Button action method, then the rest will be done by the IOS & FaceBook Inbuilt framework :)
You can do something like this:
Facebook* facebook = [[Facebook alloc] initWithAppId:@"YOUR_FACEBOOK_APP_ID" andDelegate:self];NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"My Title", @"title", @"Come check out my app.", @"message", @"FACEBOOK_USER_ID", @"to", nil]; [facebook dialog:@"apprequests" andParams:params andDelegate:self];
You can see the list of possible parameters at this page (scroll down): http://developers.facebook.com/docs/reference/dialogs/requests/
Today with the 3.11 version
of the facebook SDK you should use this in order to send an app request to a specific friend.
NSString *facebookID = @"YOUR_FRIEND_FACEBOOK_ID"NSMutableDictionary* params =[NSMutableDictionary dictionaryWithObject:facebookID forKey:@"to"];NSString *message = @"SOME_MESSAGE";NSString *title = @"TITLE";FBSession *facebookSession = [PFFacebookUtils session]; //You may changed this if you are not using parse.com[FBWebDialogs presentRequestsDialogModallyWithSession:facebookSession message:message title:title parameters:params handler: ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { }];