Morad
Morad

Reputation: 39

Facebook FBWebDialogs params invite multiple friends at once

I couldn't find anything on FB Documentation on this, but basically what I am looking for is ability to add multiple FacebookIds into Params for FBWebDialogs. Here is an Example of what I was trying to but of course it is not right:

NSMutableDictionary* params =   [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 facebookID1, @"to", 
                                 facebookID2, @"to",
                                 facebookID3, @"to",
                                 nil];

FBFrictionlessRecipientCache *friendCache = [[FBFrictionlessRecipientCache alloc] init];
[friendCache prefetchAndCacheForSession:nil];

[FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                              message:[NSString stringWithFormat:@"هل سمعت باليومي؟ برنامج iPhone إخباري روعا"]
                                                title:nil
                                           parameters:params
                                              handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                                  if (error) {
                                                      // Case A: Error launching the dialog or sending request.
                                                      NSLog(@"Error sending request.");
                                                  } else {
                                                      if (result == FBWebDialogResultDialogNotCompleted) {
                                                          // Case B: User clicked the "x" icon
                                                          NSLog(@"User canceled request.");
                                                      } else {
                                                          NSLog(@"Request Sent. %@", error);
                                                      }
                                                  }}
                                          friendCache:friendCache];

Upvotes: 1

Views: 2385

Answers (2)

Ivan
Ivan

Reputation: 181

For multiple IDs in FBWebDialogs params, you should set keys as "to[0]", "to[1]", … "to[n]":

NSMutableDictionary* params =   [NSMutableDictionary dictionaryWithObjectsAndKeys:
                             facebookID1, @"to[0]", 
                             facebookID2, @"to[1]",
                             facebookID3, @"to[2]",
                             nil];

Upvotes: 1

AdamG
AdamG

Reputation: 3718

Simple, put all those strings in an array and then the object in params is the array of strings and the key is @"to".

Upvotes: 1

Related Questions