27

Given the recent "encouragement" by Facebook to migrate to a separate messenger app, and as a followup to the {very informative!} answer to the question on URL/URI schemes supported by the Facebook app, I've been wondering whether information regarding the Facebook messenger app custom protocol of fb-messenger:// is available.

The functionality I was looking for was an ability to click a button that would open a FB-messenger chat windows with the user whose numeric Facebook ID is known. This also needed to work if the Facebook app (katana) is not installed on the device (i.e. only the messenger, orca).

I found an example of the desired deep linking (fb-messenger://user-thread/{user-id}), but that didn't seem to work. I realized that FB has a tendency of revising the URIs every once in a while, since these are generally not supposed to be available to the public (as far as I understand).

Community
  • 1
  • 1
Dev-iL
  • 23,742
  • 7
  • 57
  • 99

5 Answers5

74

After unsuccessfully searching for this information, I've decided to make a list of my own. Below is what I managed to gather so far, along with a few explanations:

These were taken from version 141.0.0.25.76 (October 21, 2017):

fb-messenger://accounts
fb-messenger://active_now
fb-messenger://addcard
fb-messenger://addmembers
fb-messenger://android_date_time
fb-messenger://android_storage
fb-messenger://autocompose
fb-messenger://autocompose_payment
fb-messenger://bots/get_started/?page_id=%s&cta_id=%s
fb-messenger://business
fb-messenger://business/
fb-messenger://business_extensions
fb-messenger://buy/mc?item_id={#%s}
fb-messenger://callsearch
fb-messenger://commerce/
fb-messenger://compose
fb-messenger://contactmigration
fb-messenger://contacts
fb-messenger://contacts/add_contacts
fb-messenger://contactuploadoptin
fb-messenger://direct_share
fb-messenger://drawoverotherapps
fb-messenger://games
fb-messenger://groupcompose
fb-messenger://groupstab
fb-messenger://groupthreadfbid/
fb-messenger://groupthreadfbid/%s
fb-messenger://ig_contact_import
fb-messenger://installupdate
fb-messenger://instant_article/?article_id=
fb-messenger://instant_article/?article_id=%s
fb-messenger://invite
fb-messenger://join_request
fb-messenger://mai
fb-messenger://messagerequests
fb-messenger://messagesearch
fb-messenger://montage
fb-messenger://montage_composer
fb-messenger://montage_mediapicker
fb-messenger://montageaudiencepicker
fb-messenger://montagecomposer
fb-messenger://networkempathy
fb-messenger://new
fb-messenger://newuser/
fb-messenger://newuser/signup?provider_name=%s&provider_page_fbid=%s
fb-messenger://nfc
fb-messenger://omni_m
fb-messenger://opengrouppreview
fb-messenger://opengrouppreview?group_preview_hash=
fb-messenger://optimistic
fb-messenger://optimistic/%s
fb-messenger://payments
fb-messenger://payments/
fb-messenger://platform
fb-messenger://platform/cta/postback/?cta_id=%s
fb-messenger://platform/share/?cta_id=%s
fb-messenger://ride_map/{%s}
fb-messenger://roomcompose
fb-messenger://rtccall
fb-messenger://sampleflows
fb-messenger://settings
fb-messenger://settings/datasaver
fb-messenger://settings/messengeronlybackup
fb-messenger://settings/montage
fb-messenger://settings/notifications
fb-messenger://settings/people
fb-messenger://settings/phoneevents
fb-messenger://settings/profilepicture
fb-messenger://settings/tincan
fb-messenger://share                    < Used for sharing multimedia, contains 
                                          several extras. See more info below.
fb-messenger://sms
fb-messenger://sms/
fb-messenger://sms/%s
fb-messenger://sms-bridge
fb-messenger://sms-takeover
fb-messenger://sms-takeover/nux?context=%s
fb-messenger://sms-takeover/nux?context=%s&thread_id=%s
fb-messenger://sms-takeover/sms_anonymous_chat_head
fb-messenger://stickerstore
fb-messenger://thread/                  < Deprecated
fb-messenger://threadkeystring
fb-messenger://threads
fb-messenger://threadsettings
fb-messenger://user
fb-messenger://user/
fb-messenger://user/%s                  < Opens chathead/conversation with user %s, where
                                          %s is the numeric fb user id. Using a username 
                                          string here crashes the orca app.
fb-messenger://user/%s?ref=%s&ref_source=%s
fb-messenger://verifyphonenux
fb-messenger://voip
fb-messenger://wave

These are some additions taken from version 293.0.0.13.232 (December 8th 2020):

fb-messenger://carrier_messaging/
fb-messenger://carrier_messaging//%s
fb-messenger://carrier_messaging_group/
fb-messenger://carrier_messaging_group//%s
fb-messenger://dialtone/switch_to_dialtone
fb-messenger://instant_games/play?game_id=
fb-messenger://m.me/
fb-messenger://payments/checkout/?product_type=pages_commerce&product_id=
fb-messenger://payments/paypal_close/
fb-messenger://payments/settings
fb-messenger://paypal_connect_fail/
fb-messenger://paypal_connect_success/
fb-messenger://settings/datasetting
fb-messenger-sametask://instant_games_contact_pick
fb-messenger-sametask://montage_mediapicker
fb-messenger-sametask://share
fb-messenger-sametask://threadsettings
fb-messenger-secure://accounts
fb-messenger-secure://accounts/triggersso
fb-messenger-secure://join_request
fb-messenger-secure://messagerequests
fb-messenger-secure://messagesearch
fb-messenger-secure://notification_to_account_switch
fb-messenger-secure://page_notification_direct_reply
fb-messenger-secure://page_rtc_notification_to_account_switch
fb-messenger-secure://rtccall/audio/%s
fb-messenger-secure://speakeasy_invite_list

Here are some URI schemes whose purpose in this app I don't know:

  • fb:// - see possible URIs of this scheme here.
  • dialtone://
  • fbinternal://
  • fb-messenger-aol://
  • fb-messenger-assistant://
  • fb-messenger-lite://
  • fb-messenger-lite-secure://
  • fb-messenger-public://
  • fb-messenger-secure://
  • fb-work://

Investigation of fb-messenger://share (from older version of this post - may be invalid):

  • Has a StringExtra called ShareType that can be: ShareType.invite, ShareType.forward, ShareType.regular.
  • Has an optional (?) StringExtra called ShareType.invitedUser.
  • Has an optional (?) StringExtra called ShareType.invitedUserDisplayName.
  • Has an optional (?) StringExtra called ShareType.inviteEntryPoint.
  • Has an optional (?) StringExtra called ShareType.invitesSentBroadcastAction.
  • (several others)

In the case of ShareType.forward:

  • Has an Extra with the tag "attachment" OR "message".
  • Has an Extra with the tag "trigger".

###Extra fields of a share Intent (tag : type):###

  • android.intent.extra.TEXT : String
  • attachment : Parcelable
  • message : Parcelable
  • page_name : String
  • page_post_id : String
  • page_target : Long
  • send_as_message_entry_point : String
  • share_attachment_url : String
  • share_caption : String
  • share_description : String
  • share_fbid : String
  • share_link_url : String
  • share_media_url : String
  • share_return_to_fb4a : Boolean
  • share_robotext : String
  • share_story_url : String
  • share_title : String
  • ShareType : String
  • target_recipients : StringArray
  • title : String
  • trigger : String

The required functionality may be achieved by using fb-messenger://user/{user-id} instead of fb-messenger://user-thread/{user-id}.

Note that {user-id} is the user's global numeric ID (e.g. for Zuck it's 4), which can be obtained (as of Nov. 2015) by parsing the html document that corresponds to the person's user name (e.g. for Zuck it's https://www.facebook.com/zuck) and extracting the "entity_id" that is found inside.

According to my latest test, app-scoped user IDs, which are usually the IDs available to developers, do not work for this!

Below is a python3 script that extracts the global ID for a known username (credit: Paul Schreiber):

#!/usr/bin/python

import requests
import re

url = 'https://www.facebook.com/zuck'
idre = re.compile('"entity_id":"([0-9]+)"')
page = requests.get(url)
print(idre.findall(page.content.decode()))

Alternatively, this site can be used to achieve the same thing.

Please also note that this method is not officially supported and might even get your app banned by FB.

Dev-iL
  • 23,742
  • 7
  • 57
  • 99
  • 1
    Thanks for that, but how do you use it? Do add query at the end of the scheme? Could you post an example of compose or sharing? Thanks! – Sebastien C. Nov 24 '14 at 12:45
  • @SebastienC. - The only thing I tried was the example mentioned at the end of my answer - `fb-messenger://user/{user-id}` - which allows you to send a message to a user, the rest were just some other commands I found in the process. What you are asking is not trivial (at least to me)... – Dev-iL Nov 24 '14 at 12:55
  • 3
    Could you pls give an example for "message" forwarding ? – alicanbatur Mar 10 '15 at 11:48
  • @alicanbatur - Unfortunately, no - I simply don't know how. See my answer to SebastienC. – Dev-iL Mar 10 '15 at 11:50
  • 1
    Thanks for response. May I ask, where did you get these information from ? – alicanbatur Mar 10 '15 at 11:51
  • Fantastic. Thank you for sharing this. This list is not easy to find and I guess Facebook does not have the intent to publish it... They want to force everybody to use their Messenger SDK. – Fabiano May 15 '15 at 20:54
  • For those having the same question as [alicanbatur](http://stackoverflow.com/questions/25467445/custom-uri-schemes-for-the-facebook-messenger?lq=1#comment46177721_25467446), see my comment [here](http://stackoverflow.com/questions/5707722/what-are-all-the-custom-url-schemes-supported-by-the-facebook-iphone-app/30231726?noredirect=1#comment51238052_30231726). – Dev-iL Jul 27 '15 at 06:21
  • Hi Dev-iL, I am looking to send some link over Facebook Messenger app from my mobile website on Chrome Browser on my mobile. I am using the facebook messenger's custom URI Scheme fb-messenger://share, as you mentioned. I used the full url as: fb-messenger://share?ShareType=ShareType.regular&share_story_url= I tried multiple options for share, but nothing works. It tries to open the app and closes. – Manik Mittal Apr 05 '16 at 07:57
  • Hi @ManikMittal - what you wrote sounds like it should be a separate question. Regardless, the only thing I ever tried doing is opening a chat window with some user.. So unfortunately, I have nothing to say about any of the other URIs... – Dev-iL Apr 05 '16 at 11:58
  • Worked great for me to open Messenger chat of my fanpage. fb-messenger://user/{user-id} (numeric id) – Maycow Moura May 23 '16 at 02:44
  • 1
    How add a text in my chat ? Uri uri = Uri.parse("fb-messenger://user/"); long a = Long.parseLong(facebookId); uri = ContentUris.withAppendedId(uri, a); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.putExtra(Intent.EXTRA_TEXT, "testo"); intent.setType("text/plain"); startActivity(intent); – Massimiliano Allegretti Feb 09 '17 at 20:05
  • @MaulikSantoki Are you sure that you're providing the correct `user-id`? Did you try it with some hardcoded value (e.g. `fb-messenger://user/4`)? [NinadKambli](http://stackoverflow.com/a/29651345/3372061) suggested in the past (now deleted answer) using `Uri uri = Uri.parse("fb-messenger://user/"); uri = ContentUris.withAppendedId(uri,[provide user id]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);`. – Dev-iL Mar 27 '17 at 10:42
  • can you have a look at this related question please: https://stackoverflow.com/questions/46841489/is-it-impossible-now-to-open-facebook-messenger-chathead-of-friends-from-my-app – Hammad Nasir Oct 20 '17 at 12:04
  • Ok but the fb-messenger://share endpoint is NOT coherent with https://developers.facebook.com/docs/sharing/messenger/ ?! who has the right answer ? ;-) – Dam Fa Nov 13 '17 at 12:14
7

With current version Facebook on android automatically ask user to open the app or open in chrome when you use their domain www.messenger.com It's better to just redirect user to this url and let facebook handle it

https://www.messenger.com/t/{username-or-page-name-here}

Intent intent;
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.messenger.com/t/{username-or-page-name-here}"));
startActivity(intent);
Nawwar Elnarsh
  • 1,049
  • 16
  • 28
3

This simply share a link

<a href="fb-messenger://share?link=encodedLink"></a>
  • 2
    Is there a way to add text to the message and not just the link? – kfiroo Feb 19 '17 at 14:13
  • It works great in a browser / mobile-browser but doesn't work at all in the "Facebook app" or "Messenger app" (the in-app browser that opens when clicking on a link inside Facebook). Any solution ? – Dam Fa Nov 13 '17 at 12:09
1

Using chrome intents for Android: The below code opens FB messenger if installed. Else redirects to fallback URL.

<a href="intent://user/<yourid>/#Intent;scheme=fb-messenger;package=com.facebook.orca;S.browser_fallback_url=http://yourfllbackweburl;end"> Open Messenger</a>
LEE
  • 3,335
  • 8
  • 40
  • 70
1

I know it is late but i hope it can help others

For my case i wanted to open my page messenger bubble if installed of course

So here what worked for me :

messengerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String messengerUrl ;
                if (isMessengerAppInstalled()) {
                    Toast.makeText(ServiceClient.this, "messenger is installed , open app bubble", Toast.LENGTH_SHORT).show();
                    messengerUrl = "fb-messenger://user/475527699675914/";
                } else {
                    Toast.makeText(ServiceClient.this, "messenger is not installed , open messenger in browser", Toast.LENGTH_SHORT).show();
                    messengerUrl = "https://www.messenger.com/t/475527699675914/";
                }
                Intent messengerIntent = new Intent(Intent.ACTION_VIEW);
                messengerIntent.setData(Uri.parse(messengerUrl));
                startActivity(messengerIntent);


            }
        });

public boolean isMessengerAppInstalled() {
        try {
            getApplicationContext().getPackageManager().getApplicationInfo("com.facebook.orca", 0);
            return true;
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
    }
waghydjemy
  • 168
  • 1
  • 12
  • Your `isMessengerAppInstalled` method can be improved by having it also detect the Lite version of the FB messenger (`com.facebook.mlite`, https://play.google.com/store/apps/details?id=com.facebook.mlite). Perhaps it's also worth clarifying what makes this answer more than a combination of previous answers. – Dev-iL Oct 03 '19 at 13:36
  • @Dev-iL yeah checking for mlite is a plus for the answer , you can edit for more precise information – waghydjemy Oct 03 '19 at 13:45