Facebook Messenger SDK for sharing text to a specific user

All I want to do is link my link to an application in FB messenger so that the user can send a message to his friend. I have the Fb id of all my users, I figured I could use this to open the messenger for the user stream.

The SDK provides only ways to send media files, but does not allow the user to send plain text. How can I allow a user to send a message via messenger to his friend from my application?

I tried this

UIImage *image = [UIImage imageNamed:@"test.png"]; [FBSDKMessengerSharer shareImage:image withOptions:nil]; 

And it works as expected; it comes to the messenger with the finished image and allows me to select users and allows me to enter more text.

How can I achieve the same functionality without having to send via media? (using nil as the image is not working).

And how can I use such a call to pre-populate the receiving user based on the FB ID?

+4
source share
2 answers

SDKs do not support starting a simple conversation between two users without any content (images, videos, links, etc.) that must be entered manually, and the message must be entered manually, symbol by symbol by the user in any case, filling in platform is not allowed.

You can check the documentation for the Send button on iOS or the documents for the Messenger Platform to check all the options that you have.

0
source

Facebook Messenger SDK for sharing text to a specific user

- (void) messengerclicked {

 NSLog(@"messenger tapped"); NSString * urlWhats = [NSString stringWithFormat:@"fb-messenger://user-thread/ENTER NUMERIC ID OF FACEBOOK PROFILE/"]; NSURL * facebookURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; if ([[UIApplication sharedApplication] canOpenURL: facebookURL]) { [[UIApplication sharedApplication] openURL: facebookURL]; } else { // Cannot open facebook UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"brand name" message:@"Fb-Messenger is not installed. \n Press Ok to Download and Install " preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *actionOk = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { NSString *iTunesLink = @"itms://itunes.apple.com/us/app/messenger/id454638411?mt=8"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]]; }]; //You can use a block here to handle a press on this button [alert addAction:actionOk]; [self presentViewController:alert animated:YES completion:nil]; } 

}

0
source

All Articles