Open Facebook Messenger from iOS app

Denisa Toderean picture Denisa Toderean · Jul 30, 2014 · Viewed 10.7k times · Source

Does anyone know how can I open the Facebook messenger application with a pre-filled text?

For example, to open the messenger app at a specified user, you can write the following:

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

For Whats app is very easy:

NSURL *whatsappURL = [NSURL URLWithString:[NSString stringWithFormat:@"whatsapp://send?text=%@", @"String to post here"]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
    [[UIApplication sharedApplication] openURL: whatsappURL];
}

Answer

Sergey Grischyov picture Sergey Grischyov · Jul 30, 2014

There is such a function but it exists only in Facebook's SDK.

Look at this - https://developers.facebook.com/docs/ios/share#message-dialog