Scenario: I would want to share the post to the wall of only selected friends.
Prerequisites followed:
Out of the entire list of FB Friends, select only the necessary friends and create an Array
Steps Tried:
Trial 1: Use FBWebDialogs
and call method + (void)presentFeedDialogModallyWithSession:(FBSession *)session parameters:(NSDictionary *)parameters handler:(FBWebDialogHandler)handler;
In the Parameters dictionary, set value for "to".
Works perfectly fine when the recipient is only one. Cannot share if the recipient is more than one.
Trial 2: Use FBDialogs
and call + (FBAppCall *)presentShareDialogWithParams:(FBShareDialogParams *)params clientState:(NSDictionary *)clientState handler:(FBDialogAppCallCompletionHandler)handler;
In the FBShareDialogParams
, set the Array of Friends.
works fine. But works only when the Facebook App is installed. Else doesnt work.
...
Can some please help me solve this problem:
- Share on wall of multiple Friends.
- Should work with or without the
Facebook App being installed on phone.
Thanks
You must do something like:
FBShareDialogParams *p = [[FBShareDialogParams alloc] init];
p.friends = friendIdsArray;`
p.link = url;
//check if the FB app is installed and can use this method
if ([FBDialogs canPresentShareDialogWithParams:p]) {
[FBDialogs presentShareDialogWithParams:p
clientState:nil
handler:^(FBAppCall *call,
NSDictionary *results,
NSError *error) {
//do some error checking
}
// fallback to what is essentially a webview
else {
// string of comma separated Facebook Ids
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"1234,5678", @"to", nil];
NSString *message = @"I love Objective-C";
[FBWebDialogs presentRequestsDialogModallyWithSession:[FBSession activeSession]
message:message
title:nil
parameters:params
handler:^(FBWebDialogResult result,
NSURL *resultURL, NSError *error) {
// do some error checking
}
This is what I use, the only problem I'm finding is that there appears to be some unknown limit to the number of Facebook Ids you can include when sending out a request. It varies and depends on factors I can't find documented. I think FB is trying to keep people from abusing/spamming people, for good reason....