skip to Main Content

I am wondering if it is possible to share/send a url link and other media from iOS app via Facebook Messenger app without having to open UIActivityViewController‘s activity sheet first, which in addition shows a number of other apps which can handle the intended data and does not allow to exclude apps only UIActivityTypes. I would like to present a FB Messenger dialog with pre-filled url link immediately after a button tap, so no dialog with multiple other apps.

Facebook documentation suggests we should use FB SDK in such cases: https://developers.facebook.com/docs/sharing/ios#message. But what is beyond me is that iOS seems to have a “native access” to the Messenger app (and other apps), but there is no good API which could facilitate some UI customisation.

Any idea if there is a way to directly open FB Messenger with pre-filled message without needing to present UIActivityViewController‘s activity sheet or installing FB SDK?

EDIT: Let me clarify, I would like to share a url link or other media, it is not necessary that the message is pre-filled with text.

2

Answers


  1. Chosen as BEST ANSWER

    After lots of searching I can confirm that it is not possible to share text or other media via Facebook Messenger without using their FB SDK as they do not provide URL schemes for that.


  2. You can share a link via messenger in this way

    let urlStr = String(format: "fb-messenger://share/?link=%@", sharelink!)
    let url  = NSURL(string: urlStr)
    
    if UIApplication.shared.canOpenURL(url! as URL) {
        UIApplication.shared.open(url! as URL, options: [:]) { (success) in
            if success {
                print("Messenger accessed successfully")
            } else {
                print("Error accessing Messenger")
            }
        }
    } else {
        // show Install Messenger
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search