Open particular user's facebook messenger with FBSDKMessenger

642 views Asked by At

I want to share link and text with particular user via FBSDKMessenger. I have done all the code for this and everything is working fine but only one problem is coming when user open messenger, user has to select friend manually.

Is there any way to preselect that friend by it's FBID?

Here is my code

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentURL = [NSURL URLWithString:[dicShare valueForKey:keyContentURL]];
    content.contentTitle = [dicShare valueForKey:keyContentTitle];
    content.contentDescription = [dicShare valueForKey:keyContentDescription];

    FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
    messageDialog.delegate = delegate;
    if ([messageDialog canShow])
    {
        [FBSDKMessageDialog showWithContent:content delegate:delegate];
    }
    else
    {
        UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:localize(@"title_Flare") message:[dicShare valueForKey:keyShareAlertMessage] delegate:nil cancelButtonTitle:localize(@"Ok") otherButtonTitles:nil];
        [warningAlert show];
    }
2

There are 2 answers

0
Björn Kaiser On BEST ANSWER

No, this is not supported. You can prepare the content (just like you did) and then use the FBSDKMessageDialog to link the user to Messenger where they select the friends they want to send the message to.

0
chemic On

If you want to open Facebook Messenger chat with a right person from your own iOS app, you can use this type of approach. UID is facebook id with whom chat is going to be opened.

Written in SWIFT

let messengerUrl: String = "fb-messenger://user-thread/" + String(uid)
UIApplication.sharedApplication().openURL(NSURL(string: messengerUrl)!)