My goal:
- Allow user to send (or attach) a video clip to a message
- Allow receiver to read (not playing) the video when it is received
- Not using an additional server to host these messages or videos. In other words, I want everything to be done within the message extension framework.
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 would like to let the receiver read the media file (video). However, it doesn't seem to be possible.
override func didSelect(_ message: MSMessage, conversation: MSConversation) {
// message doesn't seem to contain any media content
}
2) Using an 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)
}
})
}
This way the attachment (video) is opened by the system's default App. Which means my App couldn't read the video.
Questions:
- Is it possible to let receiver read the video sent by sender?
- Is it possible to insert an attachment AND insert an MSMessage at the same time?
- Or is there any other way that I could do what I want?