Deep linking to Facebook Messenger

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 02:31:41
Parker

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.

user1508000

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": "..." } } ] } ] }

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!