Script to open facebook messenger app chat

Asked

Viewed 1,077 times

3

I’m creating a app, and wanted to insert a button to open a conversation from a particular page of facebook, but by the messenger application and not by the browser, someone knows if you have how to?

2 answers

1

To open a certain thread on Facebook Messenger just use the Scheme URL fb-messenger://user/{user-id}. The Parameter user-id is a long integer as can be seen in https://developers.facebook.com/docs/graph-api/reference/user/.

More information in that OS response (in English).

Remember that from iOS 9 the Messenger URL Scheme (fb-messenger) needs to be placed on your Whitelist.

Also recommend that you check with canOpenURL: first and make a fallback if the user does not have the messenger installed.

  • Man, some time ago I wanted to do something like this. So I ended up finding a solution that even serves for Whatsapp and is very simple to implement. It might help you: lucianobragaweb.github.io/integrate-Whatsapp-no-site

1

Open a page conversation you mean a post, right?

You can try it this way:

NSURL *url = [NSURL URLWithString:@"fb://post/<id_do_post>"];
[[UIApplication sharedApplication] openURL:url];

Now if you’re talking about opening someone’s fanpage or profile only changes the beginning of URL, example:

NSURL *url = [NSURL URLWithString:@"fb://profile/<id_da_page_ou_perfil>"];
[[UIApplication sharedApplication] openURL:url];

More options you can see here:

http://wiki.akosma.com/IPhone_URL_Schemes#Facebook

  • That answer is not about what was asked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.