Sending message from iOS application to FB messenger app

1.6k views Asked by At

I need to send a pre-filled message from my app to the fb messenger app. I followed the post SO Link. The custom URL just opens the fb messenger app but shows no change.

Below is the code that I have tried:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb-messenger://contacts"]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb-messenger://share"]];

The above code just opens the fb messenger app, it does not navigate to contacts page or the compose screen.

Has anybody faced the same situation? Does anybody know the code for sending the text I want to share from the app? Examples would be appreciated.

1

There are 1 answers

0
Pinank Lakhani On

Go with following code its will works for you

NSURL *fbURL = [NSURL URLWithString:@"fb-messenger://user-thread/USER-ID/"];
if ([[UIApplication sharedApplication] canOpenURL: fbURL]) {
[[UIApplication sharedApplication] openURL: fbURL];
}