How to share link to Facebook Messenger app in iOS (Objective-C)?

3.7k views Asked by At

I'm using fb ios sdk for sharing link to people connected on fb messenger. There is no way I can find to share link on Messenger app.

FBSDKMessengerSharer class only can share audio, video and image to Messenger. How can I open Messenger app with initiating particular link? Please help me soon.

3

There are 3 answers

3
Sri On

Your are right. My understanding as well is, the API has no support at this point beyond media sharing to messenger using FBSDKMessengerShareButton. I scanned through this and https://developers.facebook.com/docs/ios/reference and there is nothing.

If your URL is GIF or WebP you can try using the sourceURL attribute of FBSDKMessengerShareOptions.

Thanks

0
Heberti Almeida On

If you want to share a link you have to install FBSDKShareKit and not FBSDKMessengerShareKit.

let content = FBSDKShareLinkContent()
content.contentURL = URL(string: "http://google.com")
content.imageURL = URL(string: "http://google.com/image.png")
content.contentTitle = "Some link title"

let messageDialog = FBSDKMessageDialog()
messageDialog.shareContent = content
messageDialog.show()

Take a look here for more options: https://developers.facebook.com/docs/sharing/ios

0
Papon Smc On

if you use swift pages facebook same me,and don't know to share link into Messenger app will try this

  1. add lib facebook or swift pages facebook in you project
  2. write code to open
let content = ShareLinkContent()

    content.contentURL = URL(string: linkShare)!

    let messageDialog = MessageDialog()
    messageDialog.shareContent = content
    messageDialog.show()

done.

try run code.

** if you can't share link try check below picture

enter image description here

1.you will see url fail

  1. copy url in your log (my log is "fb-messenger-share-api").

3.add link in info.plist enter image description here