1

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];
Morad
  • 39
  • 3
  • Morad, off-topic, but u should not have multiple Keys with same text. In your example, you have added `@"to"` thrice. This will not work. If you print the dictionary, there will be only one entry. – Roshit Oct 28 '13 at 19:28

2 Answers2

1

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

AdamG
  • 3,718
  • 2
  • 18
  • 28
  • I doubt if that will work. "to" parameter takes only one Facebook ID. Multiple IDs result in an error. Similar Question: http://stackoverflow.com/questions/19499378/ios-post-on-wall-of-selected-fb-friends – Roshit Oct 28 '13 at 19:15
  • "In the FBShareDialogParams, set the Array of Friends. works fine. But works only when the Facebook App is installed. Else doesnt work." He was just wrong and didn't understand you don't get a notification if the app isn't installed but you still get an app request alert on the lower left side of the news feed in the app center. – AdamG Oct 28 '13 at 19:19
  • ok.. But from my app, will I be able to share using FBShareDialogParams, even if FB App is not installed on the Device? – Roshit Oct 28 '13 at 19:24
  • Yes. As I said in my last message, it does send a request to them the way facebook wants you to, which is through the app center. – AdamG Oct 28 '13 at 20:47
  • If you want to post on their wall you should not use the requests dialogue, but the feed dialogue: http://stackoverflow.com/questions/12122098/facebook-ios-sdk-3-x-feed-dialog-is-gone – AdamG Oct 28 '13 at 20:53
  • Adam, I wasn't enquiring about the availability of Facebook app on the Receiver end. My question was, If I as a sender do not have Facebook app on my iPhone, and I try invoking the `FBShareDialogParams` along with the "to" details in my App, will it still work. Please let me know if your answer still holds good. – Roshit Oct 28 '13 at 21:17
  • I mean, if the user is not logged in through Facebook, it won't work. But, if the user is logged in through Facebook on your app then they have the app on their iPhone, in which case, it will work. – AdamG Oct 31 '13 at 02:47
  • No.. Even users who don't have Facebook, will be able to login, cuz FB redirects them to the Mobile Browser for Login and Other Authorizations. – Roshit Oct 31 '13 at 13:31
  • is that worked for you? I am getting "[__NSArrayI length]: unrecognized selector sent to instance". this error when using NSArray of facebook ids. – Devel Dec 30 '13 at 10:59
1

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];
Ivan
  • 181
  • 6