0

I used this code to invite friend in my iOS App

[FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                              message:@"Test1"
                                                title:@"Title 1"
                                           parameters:parameters
                                              handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
 {
     if(error)
     {
         NSLog(@"Some errorr: %@", [error description]);
         UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Invitiation Sending Failed" message:@"Unable to send inviation at this Moment, please make sure your are connected with internet" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
         [alrt show];

     }
     else
     {
         if (![resultURL query])
         {
             return;
         }

         NSDictionary *params = [self parseURLParams:[resultURL query]];
         NSMutableArray *recipientIDs = [[NSMutableArray alloc] init] ;
         for (NSString *paramKey in params)
         {
             if ([paramKey hasPrefix:@"to["])
             {
                 [recipientIDs addObject:[params objectForKey:paramKey]];
             }
         }
         if ([params objectForKey:@"request"])
         {
             NSLog(@"Request ID: %@", [params objectForKey:@"request"]);
         }
         if ([recipientIDs count] > 0)
         {
             //[self showMessage:@"Sent request successfully."];
             //NSLog(@"Recipient ID(s): %@", recipientIDs);
             UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Invitation(s) sent successfuly!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
             [alrt show];

         }

     }
 }
                                          friendCache:nil];

//sample code 2

 [FBWebDialogs
     presentRequestsDialogModallyWithSession:nil
     message:@"Yeeeeep Check my app"
     title:@"Burp War"
     parameters:nil
     handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
         if (error) {
             // Error launching the dialog or sending the request.
             NSLog(@"Error sending request.");
         } else {
             if (result == FBWebDialogResultDialogNotCompleted) {
                 // User clicked the "x" icon
                 NSLog(@"User canceled request.");
             } else {
                 // Handle the send request callback
                 NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
                 if (![urlParams valueForKey:@"request"]) {
                     // User clicked the Cancel button
                     NSLog(@"User canceled request.");
                 } else {
                     // User clicked the Send button
                     NSString *requestID = [urlParams valueForKey:@"request"];
                     NSLog(@"Request ID: %@", requestID);
                 }
             }
         }
     }];

But unfortunately this is not working getting error "Game request only for game app". How to get email id of friends? thanks in advance.

Avijit Nagare
  • 8,482
  • 7
  • 39
  • 68

1 Answers1

1

The new graph api only supports User Invitable Friends only for games https://developers.facebook.com/docs/graph-api/reference/v2.5/user/invitable_friends

https://developers.facebook.com/docs/games/services/gamerequests

Note: There is no way for apps to obtain email addresses for a user's friends.

facebook policy statement states this

How can I get facebook friends list email addresses?

How to get a facebook user's friends emails

Community
  • 1
  • 1
user3354805
  • 135
  • 8