2

As per doc:

@method     insertAttachment:withAlternateFilename:completionHandler:
@abstract   The NSURL instance provided in the URL parameter is inserted into the Messages.app
input field. This must be a file URL.
@param      URL                The URL to the media file to be inserted.
@param      filename           If you supply a string here, the message UI uses it for the attachment. Use an alternate filename to better describe the attachment or to make the name more readable.
@param      completionHandler  A completion handler called when the insert is complete.
 */
open func insertAttachment(_ URL: URL, withAlternateFilename filename: String?, completionHandler: (@escaping (Error?) -> Swift.Void)? = nil)

Where it says for

filename ---> If you supply a string here, the message UI uses it for the attachment. Use an alternate filename to better describe the attachment or to make the name more readable.

And my code is:

if let conversation = activeConversation {
    conversation.insertAttachment(fileURL, withAlternateFilename: "This is file Description.", completionHandler: nil)
}

But it is not showing anywhere in message app.

I am sending video file here.

I want to show that description on navigation bar title when user click on message or below the MSMessage if possible.

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
  • Try to specify file's extension when setting alternate filename, for example: "This is file Description.png" – nsinvocation Sep 02 '16 at 13:27
  • Thanks for the comment but It doesn't help. @azimov – Dharmesh Kheni Sep 02 '16 at 13:54
  • 2
    Did you ever figure this out? I am running across the same issue! – Prasanth Mar 09 '19 at 19:41
  • 2019, and still a bug. – Daniel Dec 16 '19 at 07:24
  • The Swift version of this is broken. The objective-C version of this works as expected. Have to import Objective-C .h and .m file and supply a bridging header to your Swift project. Works great and the filename is correct – Andrew Bennett Jan 05 '20 at 18:31
  • FYI: this also affects the `sendAttachment(_:withAlternateFilename:completionHandler:)`, so there is not any workarounds in the API. I see this on Xcode 11.3.1. – benc Jun 15 '20 at 21:38
  • I see this working in Xcode 12.1 and in iOS 14. I don't know where it was fixed (Xcode vs. iOS). – benc Jan 17 '21 at 08:31

2 Answers2

0

As of WWWDC 2020, I think this was fixed via Xcode 12 or iOS 14, because I saw it in Xcode 11, but my updated builds work.

benc
  • 1,381
  • 5
  • 31
  • 39
-4

As per latest doc, try func addAttachmentURL(_ attachmentURL: NSURL, withAlternateFilename alternateFilename: String?) -> Bool

https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMessageComposeViewController_class/index.html#//apple_ref/occ/instm/MFMessageComposeViewController/addAttachmentURL:withAlternateFilename:

Ankit Thakur
  • 4,739
  • 1
  • 19
  • 35
  • FYI: That isn't just the wrong class documentation, that's the wrong `framework` (in case you were wondering why you got so many downvotes, thats my guess). – benc Jun 15 '20 at 19:34