Question

I am using the FBDialogs to open Facebook Messenger (if user has it installed on the device) to send a personal message. However I cannot already preselect friends in my app (messenger always gives me a list and prompts me to select there).

FB Messenger

I am using presentMessageDialogWithParams:clientState:handler: which receives FBLinkShareParams object.

FBLinkShareParams friends array

An array of NSStrings or FBGraphUsers to tag in the post. If using NSStrings, the values must represent the IDs of the users to tag.

But when I send FBGraphUsers they are not preselected in messenger app. Should they? Or is this just a "tag a friend" feature?

My code:

NSMutableArray *inviteFriends = [[NSMutableArray alloc] init];

FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                              NSDictionary* result,
                                              NSError *error) {
    NSArray* friends = [result objectForKey:@"data"];
    NSLog(@"Found: %i friends", friends.count);
    for (NSDictionary<FBGraphUser>* friend in friends) {
        if ([friend.name isEqualToString:@"XXX"]) {
            NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id);
            [inviteFriends addObject:friend];
        }
    }

    FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
    params.link = [NSURL URLWithString:@"https://developers.facebook.com/docs/ios/share/"];
    params.name = @"Message Dialog Tutorial";
    params.caption = @"Build great social apps that engage your friends.";
    params.picture = [NSURL URLWithString:@"http://i.imgur.com/g3Qc1HN.png"];
    params.description = @"Send links from your app using the iOS SDK.";
    params.friends = inviteFriends;


    // If the Facebook app is installed and we can present the share dialog
    if ([FBDialogs canPresentMessageDialogWithParams:params]) {
        [FBDialogs presentMessageDialogWithParams:params clientState:nil handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
            //
        }];
    }
}];
Was it helpful?

Solution

The "friends" and "place" parameters are ignored by Messenger since those are specific for tagging, and Messenger doesn't support tagging.

You cannot specify users to preselect using the message dialog.

We will update the docs to reflect this in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top