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: FB ID

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:

FB ID from URL

answered Nov 21 2022 at 23:45

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

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.

salleycanualal.blogspot.com

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

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel