4

I've seen other topics like this: launch facebook app from other app and tried some of the URIs listed there, but I can't figure out how to start the facebook chat with a specific friend.

Is there an official page that describes the IntentUriHandler and all the allowed URIs with their params?

Thanks, Lorenzo

Community
  • 1
  • 1
Lorenzo S
  • 1,397
  • 13
  • 25
  • open you logcat and check what intent is being fired when a chat is opened from facebook app and copy the URI. Too lazy to check myself right now ;) – Amol Gupta Jan 23 '12 at 15:27
  • first of all thanks for your reply. I've already checked what intent is fired, but I can't call it myself (security exception), as described in this thread: http://stackoverflow.com/questions/4116273/permission-denial-for-intent-to-external-activity . It seems like some activities can only be called by the Facebook app (and this is why the IntentUriHandler exists in the Facebook app). – Lorenzo S Jan 23 '12 at 18:21
  • Hi lorenzo, iam also facing the same issue,can u explain how to open facebook(or) facebook-chat app from my app.Thanks in advance. – sandeep Nov 28 '13 at 10:35
  • @sandeep: hi, if you're just looking for the way to open the facebook app then it's "easy", look for example this [thread](http://stackoverflow.com/questions/4191492/launch-facebook-app-from-other-app). Inside there are even some protocols string to open chat, inbox, etc...How to exactly open a chat with a specific user, i still don't know... :) – Lorenzo S Nov 28 '13 at 14:02
  • @LorenzoS thank for ur help.The issue is solved. – sandeep Nov 29 '13 at 05:20

2 Answers2

9

found it here: https://developers.facebook.com/docs/messenger-platform/discovery/m-me-links#format

http://m.me/{#user_id}

you can use this URI to open messaging with a friend with known id.

You can start the intent like below

startActivity(new Intent(android.action.VIEW, "http://m.me/{#user_id}"));
Community
  • 1
  • 1
tasomaniac
  • 10,234
  • 6
  • 52
  • 84
  • Where did you find it? Any other features available for this, like adding text? Please check this question I've asked about this topic: http://stackoverflow.com/q/35972329/878126 – android developer Mar 14 '16 at 08:14
  • 1
    I find this from looking at Facebook apps AndroidManifest file. I don't think you can add message text. – tasomaniac Mar 14 '16 at 08:22
  • Thank you. So it's not an official API, and might break some time in the future? Also, do you know how to do it for other apps and social networks, like WhatsApp, Twitter, Telegram, Hangouts, Line,... ? If so, please check the thread I've made. – android developer Mar 14 '16 at 08:24
  • 1
    It is not official and can be disabled in the future. So if you are going to add this, guard against it. – tasomaniac Mar 14 '16 at 08:26
  • Thank you again. Please check the thread I've made. You can also put your answer there. – android developer Mar 14 '16 at 08:27
  • Also, I think you have a mistake, as the first parameter of the intent cannot be found this way, and the second is supposed to be a URI. – android developer Mar 14 '16 at 08:41
  • Thanks, but if user never login in FB messenger app, then it navigate to messenger login process but at last it wont open the particular user chat window with whom I have to chat .How to handle such scenario? – Suhas Bachewar Dec 07 '16 at 07:05
  • @SuhasBachewar it is almost impossible to handle that scenario. You would never be able to know that the user is logged in or not in Facebook messenger. – tasomaniac Dec 19 '16 at 14:11
6
startActivity(new Intent(Intent.ACTION_VIEW,
              Uri.parse("fb://messaging/" + userId)));
Guy
  • 12,250
  • 6
  • 53
  • 70
  • In some device its not opening/navigating to FB-chat screen of Userid.Iam using the above code to message with the userid(Friend) – sandeep Nov 29 '13 at 12:48
  • Any chance you know how to do it on other chatting apps? If so, please check this thread: http://stackoverflow.com/q/35972329/878126 – android developer Mar 14 '16 at 09:11
  • Thanks, but if user never login in FB messenger app, then it navigate to messenger login process but at last it wont open the particular user chat window with whom I have to chat .How to handle such scenario? – Suhas Bachewar Dec 07 '16 at 07:05
  • ActivityNotFound Exception for Uri fb://messaging/ – Pankaj Jan 31 '18 at 12:28
  • @Pankaj You don't have Messenger installed on your device – hiddeneyes02 Apr 13 '18 at 11:52