15

How can I launch FaceBook Messenger (if installed) with a compose Windows to a specific FB ID.

If messenger is not installed, can we launch FaceBook app and have the compose Windows open to a specific FB ID.

In the rare instance if no Facebook apps are installed, can we launch mobile Safari with the compose window?

AstroCB
  • 11,800
  • 20
  • 54
  • 68
software is fun
  • 5,999
  • 15
  • 49
  • 99
  • Check [this](http://wiki.akosma.com/IPhone_URL_Schemes#Facebook) for some hints related to your question. – Javier Cadiz Nov 25 '13 at 18:00
  • I did check that but it's for FaceBook only and half the FaceBook URL's don't work anymore. FaceBook must have changed it's internal URL scheme. – software is fun Nov 25 '13 at 18:40
  • 1
    I have been looking and experimenting, but I can't figure out what their URL scheme is. fb-messenger:// works, but I can't get to a specific conversation from either a person or a group. – Ustice Nov 26 '13 at 22:41
  • Hi guys, [this may be of help](http://stackoverflow.com/questions/25467445/custom-uri-schemes-for-the-facebook-messenger/25467446). – Dev-iL Aug 25 '14 at 04:26

4 Answers4

24

The URL scheme is fb-messenger://user-thread/{user-id}. I just build my app with fb-messenger URL scheme as Viewer and trapped the URL on the UIApplication delegate. The user-id parameter is long integer one, as in https://developers.facebook.com/docs/graph-api/reference/user/

enter image description here

tia
  • 8,627
  • 1
  • 24
  • 41
  • user-id is the same as UID (a numeric string)? – software is fun Dec 02 '13 at 14:10
  • 1
    Hey Tia, quick question. How do you return to your app after the user has "finished" with fb-messenger ? – user1349663 Jun 02 '14 at 09:54
  • 1
    @user1349663 You can achieve that using Facebook's App Links: http://applinks.org – Pontus Jan 05 '15 at 08:26
  • 2
    With graph 2.0, FB introduced "AppScopedIds" - which has broken the deeplinking to Messenger, since messenger doesn't understand app-scoped ids. However, Facebook profile link understands app-scoped ids - so it seems like a bug in messenger - they should ideally be able to translate app-scoped ids to the right fb id correctly. – Pratik Stephen Oct 08 '15 at 02:36
  • 2
    Hi, Can I use this URL to send individual message? – user3575114 Oct 27 '15 at 06:54
  • thanks for the great answer :) P.S. you can probably check if the messenger app is installed by using the canOpenURL method of UIApplication as described in this answer: http://stackoverflow.com/a/16013030 – Alex Zak Dec 30 '15 at 16:50
19

Just use https://m.me/USER_ID.

This will deep link the user to the native Messenger app if available and start a conversation with the user identified by its USER_ID.

If the native app is not available on the device, it will open the messenger web app in a new browser.

olivierlesnicki
  • 191
  • 1
  • 2
6

You can only launch an installed app using the Custom -URL. But you cannot check whether the app is installed or not (Second part of your question.) Reason: If it would have been possible to check the installed apps in iOS, One can then create app which will get information of all installed apps.

facebook Custom URL latest updates:

fb://album/%@
fb://album/(aid)
fb://album/(aid)/cover
fb://album/(initWithAID:)
fb://album/(initWithAID:)/cover
fb://album/new
fb://albums
fb://birthdays
fb://birthdays/(initWithMonth:)/(year:)
fb://birthdays/(month)/(year)
fb://chat/(fbid)
fb://chat/(initWithUID:)
fb://chat/(user.fbid)
fb://contactimporter
fb://contactimporter/invites
fb://contactimporter/legalese
fb://contactimporter/modal
fb://event/%@
fb://event/%llu
fb://event/(event.fbid)/members/(rsvpStatus)
fb://event/(fbid)
fb://event/(fbid)/members/attending
fb://event/(fbid)/members/declined
fb://event/(fbid)/members/not_replied
fb://event/(fbid)/members/unsure
fb://event/(fbid)/rsvp
fb://event/(initWithEventId:)
fb://event/(initWithEventId:)/members/(rsvpStatus:)
fb://event/(initWithEventId:)/rsvp
fb://events
fb://events/
fb://faceweb/(initWithURL:)
fb://facewebmodal/(initWithURL:)
fb://feed
fb://feed/%@
fb://feed/(filter.filterKey)
fb://feed/(initWithFilterKey:)
fb://feedfilters
fb://findfriends
fb://findfriends/legalese
fb://findfriends/modal
fb://friends
fb://friends/picker
fb://friends/sync
fb://friends/sync/(removeData:)
fb://friends/sync/disconnect
fb://friends/sync/legalese
fb://group/(fbid)/members
fb://group/(initWithGroupId:)/members
fb://groups
fb://launcher
fb://mailbox
fb://mailbox/(folder)
fb://mailbox/(initWithFolder:)
fb://mailbox/(initWithFolder:)/(tid:)
fb://mailbox/(mailbox.folder)/(tid)
fb://mailbox/compose
fb://mailbox/compose/(fbid)
fb://mailbox/compose/(initWithUID:)
fb://map
fb://messaging
fb://messaging/(folder)
fb://messaging/(initWithFolder:)
fb://messaging/(initWithFolder:)/(tid:)/participants
fb://messaging/(initWithFolder:)/thread?tid=(tid:)
fb://messaging/(mailbox.folder)/(urlEscapedTid)/participants
fb://messaging/(mailbox.folder)/thread?tid=(urlEscapedTid)
fb://messaging/compose
fb://messaging/compose/(fbid)
fb://messaging/compose/(initWithUID:)
fb://messaging/original_message?mid=(commentId)
fb://messaging/original_message?mid=(initWithMessageId:)
fb://nearby
fb://note/%@
fb://note/(initWithNoteId:)
fb://note/(initWithNoteId:)/edit
fb://note/(noteId)
fb://note/(noteId)/edit
fb://note/compose
fb://notes
fb://notifications
fb://online
fb://online#offline
fb://online#online
fb://page/(page.id)
fb://pages
fb://photo/%@/0/%@
fb://photo/(album.user.fbid)/(album.aid)/(pid)
fb://photo/(album.user.fbid)/(album.aid)/(pid)/feedback
fb://photo/(fbid)/profilepic
fb://photo/(initWithProfilePicturesUID:)/profilepic
fb://photo/(initWithUID:)/(aid:)/(pid:)
fb://photo/(initWithUID:)/(aid:)/(pid:)/feedback
fb://photosapp
fb://place/%@
fb://place/(initWithPageId:)
fb://place/(targetId)
fb://place/addfriends
fb://place/addphoto
fb://place/create
fb://places
fb://places/%lld/%lld
fb://places/(initWithCheckinAtPlace:)/(byUser:)
fb://places/legalese/tagged/%lld/%lld
fb://places/legalese/tagged/(initWithTaggedAtPlace:)/(byUser:)
fb://post/%@
fb://post/%@_%@
fb://post/(initWithPostId:)
fb://post/(initWithPostId:)/tagged
fb://post/(postId)
fb://post/(postId)/tagged
fb://post/(postId)/untagSelf
fb://post/(untagSelfFromPostWithId:)/untagSelf
fb://profile
fb://profile/
fb://profile/%@
fb://profile/%lld
fb://profile/(addFan:)/addfan
fb://profile/(fbid)
fb://profile/(fbid)/addfan
fb://profile/(fbid)/addfriend
fb://profile/(fbid)/fanpages
fb://profile/(fbid)/fans
fb://profile/(fbid)/favorite
fb://profile/(fbid)/friends
fb://profile/(fbid)/info
fb://profile/(fbid)/menu
fb://profile/(fbid)/mutualfriends
fb://profile/(fbid)/photos
fb://profile/(fbid)/poke
fb://profile/(fbid)/removefriend
fb://profile/(fbid)/wall
fb://profile/(initWithFBID:)/menu
fb://profile/(initWithFansUID:)/fans
fb://profile/(initWithFriendsUID:)/friends
fb://profile/(initWithInfoUID:)/info
fb://profile/(initWithMutualFriendsUID:)/mutualfriends
fb://profile/(initWithPhotosUID:)/photos
fb://profile/(initWithUID:)
fb://profile/(initWithUID:)/addfriend
fb://profile/(initWithUID:)/fanpages
fb://profile/(initWithUID:)/poke
fb://profile/(initWithUID:)/removefriend
fb://profile/(initWithWallUID:)/wall
fb://profile/(toggleFavorite:)/favorite
fb://profile/(user.fbid)/fans
fb://profile/(user.fbid)/friends
fb://profile/(user.fbid)/mutualfriends
fb://profile/0
fb://publish
fb://publish/mailbox/(initWithFolder:)/(tid:)
fb://publish/mailbox/(mailbox.folder)/(tid)
fb://publish/photo/(album.user.fbid)/(album.aid)/(pid)
fb://publish/photo/(initWithUID:)/(aid:)/(pid:)
fb://publish/post/(initWithPostId:)
fb://publish/post/(postId)
fb://publish/profile/(fbid)
fb://publish/profile/(initWithUID:)
fb://publish/profile/(owner.fbid)
fb://requests
fb://root
fb://upload
fb://upload/%@/album/%lld/%@
fb://upload/%@/checkin/%lld
fb://upload/%@/profile/%lld
fb://upload/(initWithSource:)/album/(uid:)/(aid:)
fb://upload/(initWithSource:)/checkin/(checkinId:)
fb://upload/(initWithSource:)/profile/(uid:)
fb://upload/actions
fb://upload/actions/album/(initWithUID:)/(aid:)
fb://upload/actions/album/(user.fbid)/(aid)
fb://upload/actions/checkin/(checkinId)/
fb://upload/actions/checkin/(initWithCheckinId:)
fb://upload/actions/newalbum
fb://upload/actions/profile/(fbid)
fb://upload/actions/profile/(initWithUID:)
fb://upload/actions/resume
fb://upload/album/(showUploadMenuWithUID:)/(aid:)
fb://upload/album/(user.fbid)/(aid)
fb://upload/checkin/(checkinId)
fb://upload/checkin/(showUploadMenuWithCheckinID:)
fb://upload/discard
fb://upload/profile/(fbid)
fb://upload/profile/(owner.fbid)
fb://upload/profile/(showUploadMenuWithUID:)
fb://upload/resume
fb://userset
fb://video/%@
fb://video/(playVideoWithId:)
fb://video/(videoId)
Owen Blacker
  • 3,889
  • 2
  • 33
  • 68
Aditya
  • 2,665
  • 4
  • 32
  • 28
1

sample ,It's work for me in ios

let msgUrl = URL(string: "http://m.me/{PAGE_NAME}")
UIApplication.shared.openURL(msgUrl)

reference in document of dev facebook : https://developers.facebook.com/docs/messenger-platform/discovery/m-me-links/

Papon Smc
  • 356
  • 3
  • 6