From a lot of searching, I found that using fb-messenger://user-thread/ID
can be used to deep link to Messenger and open the existing thread with the passed in FB ID or start a new thread if not existent.
It pops over to Messenger and opens a thread, but the thread is with Facebook User
and doesn't actually send. See image below. Clicking Facebook User in the header goes to a detail view with the correct user's image and name.
How do I make this work correctly?
As WizKid (FB Employee) said here:
...there is no documented way to interact with ... [Messenger] so anything you do may break at any second.
So with that in mind, it sounds like fb-messenger://user-thread/ID
has been deprecated. That being said, I decompiled the Facebook Android APK and found a line:
return Uri.parse((new StringBuilder("fb-messenger://user/")).append(Uri.encode(s)).toString());
So from what I can see, it looks like fb-messenger://user-thread/ID
has been replaced with fb-messenger://user/ID
There's also a line thats:
return Uri.parse((new StringBuilder("fb-messenger://thread/")).append(Uri.encode(s)).toString());
So fb-messenger://thread/ID
may be valid too. ID could be a user or thread ID, I didn't dig deep enough to find out.
EDIT:
Current Facebook URL is fb-messenger-public://user-thread/ID
Sorry to bring this back from the dead, but it seems that Facebook Messenger has incorporated Universal Links to quick open the Messenger app.
m.me/$USERNAME
for example: http://m.me/zuck will universally link you to message Zuckerberg.
I played with a couple params, but nothing seemed to prefill the message.
All of this has changed. Facebook released short links to connect with a brand or user's Messenger profile. The way to direct link is http://m.me/PROFILE or PAGE_NAME
If you're building bots, you can also pass in a referral parameter. I've written a bunch about this linking in to Messenger conversations.
If you want to jump to code directly, here it is:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://m.me/%ld", USER_ID]];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
Use fb-messenger-public://user-thread/<ID>
I got my ID
from the recipient ID in the facebook messenger web hook payload. e.g.
{
"object": "page",
"entry": [
{
"id": "1163189980393936",
"time": 1500325170682,
"messaging": [
{
"sender": {
"id": ""
},
"recipient": {
"id": "ID"
},
"timestamp": 1500325170640,
"message": {
"mid": "mid.$cAAQh6kd9svBjg56V0FdUllNamImF",
"seq": 2888,
"text": "..."
}
}
]
}
]
}
来源:https://stackoverflow.com/questions/31777075/deep-linking-to-facebook-messenger