How Can You Tell if Someone Is on Facebook Messenger
three Answers 3
Swift four
UI
In my app I show a user'southward Facebook ID equally a push:
Code
@IBAction func messengerButton(_ sender: UIButton) { if let id = sender.titleLabel?.text { if let url = URL(string: "fb-messenger://user-thread/\(id)") { // Attempt to open up in Messenger App first UIApplication.shared.open(url, options: [:], completionHandler: { (success) in if success == false { // Messenger is not installed. Open in browser instead. let url = URL(string: "https://m.me/\(id)") if UIApplication.shared.canOpenURL(url!) { UIApplication.shared.open(url!) } } }) } } }
User'southward Facebook ID
The user tin become another person'south Facebook ID from looking them upwards on Facebook and then observing the URL:
answered Nov 21 2022 at 23:45
Marker MoeykensMarking Moeykens
13.1k 5 gold badges 59 silver badges 57 bronze badges
I found a solution with URL Scheme:
allow userID = four let urlStr = String(format: "fb-messenger://user-thread/%d", userID) let theUrl = NSURL(string: urlStr) [UIApplication.sharedApplication() .openURL(theUrl!)]
This code will open Message application and talk to Mark.
answered Jun half-dozen 2022 at 19:51
GigaGiga
41 1 argent badge 5 bronze badges
in swift five.ane, use
guard let messenger = URL(cord: "fb-messenger://user-thread/your_id") else { render } UIApplication.shared.open(messenger)
answered Mar 18 2022 at 7:45
Not the reply yous're looking for? Browse other questions tagged ios swift facebook or ask your own question.
Source: https://stackoverflow.com/questions/37542659/how-to-open-facebook-messenger-and-direct-to-someone/47424611
0 Response to "How Can You Tell if Someone Is on Facebook Messenger"
Post a Comment