Custom URL to launch Facebook Messenger on iOS
Asked Answered
F

4

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?

Flieger answered 18/11, 2013 at 22:9 Comment(4)
Check this for some hints related to your question.Agog
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.Flieger
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.Aesculapian
Hi guys, this may be of help.Worldlywise
G
3

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/

Grevera answered 24/9, 2020 at 8:24 Comment(0)
B
25

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

Basie answered 2/12, 2013 at 3:33 Comment(6)
user-id is the same as UID (a numeric string)?Flieger
Hey Tia, quick question. How do you return to your app after the user has "finished" with fb-messenger ?Steamtight
@Steamtight You can achieve that using Facebook's App Links: applinks.orgMisfire
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.Kerseymere
Hi, Can I use this URL to send individual message?Disagree
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: stackoverflow.com/a/16013030Perique
F
22

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.

Fan answered 9/10, 2016 at 11:7 Comment(3)
This is now the most accurate answer for modern use. Works across devices and browsers.Nebula
Thank you so much for this answer. Worked for me.Caldera
This works. But in a scenario that I want to share a link without defining specific USER_ID first (I will choose who to send to later). How can I use m.me? Should it be something like https://m.me/share?link=www.google.com ?Antelope
A
8

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)
Aceae answered 2/12, 2013 at 14:46 Comment(2)
HTML Smart Tags some how can check if a specific app is installed.Flieger
None of these seem to be working for me. Did Facebook update their URL schemes again?Adrenaline
G
3

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/

Grevera answered 24/9, 2020 at 8:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.