How to send and read image / video in iOS message?

My goal:

  • Allow user to send (or attach) video clip to message
  • Allow the receiver to read (not play) the video when it is received.
  • Do not use an additional server to host these messages or videos. In other words, I want everything to be done as part of the message extension.

I tried:

1) Using MSMessage:

private func insertVideoIntoMessage(usingUrl url: URL) { if let conversation = self.activeConversation { let layout = MSMessageTemplateLayout() layout.caption = "Some caption" layout.mediaFileURL = url // Media file (video) let message = MSMessage() message.layout = layout message.url = URL(string: "some url") conversation.insert(message, completionHandler: { error in if let error = error { print("Error:", error) } }) } } 

I want the receiver to read the media file (video). However, this is not possible.

 override func didSelect(_ message: MSMessage, conversation: MSConversation) { // message doesn't seem to contain any media content } 

2) Using the attachment:

 private func insertVideoInMessage(usingUrl url: URL) { if let conversation = self.activeConversation { conversation.insertAttachment(url, withAlternateFilename: "Some file name", completionHandler: { error in if let error = error { print("Error:", error) } }) } 

Thus, the application (video) is opened by the default application for the system. This means that my application cannot read the video.

Questions:

  • Is it possible for the recipient to view the video sent by the sender?
  • Is it possible to insert an attachment AND paste MSMessage at the same time?
  • Or is there another way I could do what I want?
+6
source share

Source: https://habr.com/ru/post/1012496/


All Articles