In my iMessage App I'm trying to send a remote video file. From the documentation I can read that the property mediaFileURL
in MSMessageTemplateLayout
object should be the right point where to set the URL
The media file URL must be a file URL
This is how I'm creating the MSMessage
instance
let message = MSMessage()
message.shouldExpire = false
let layout = MSMessageTemplateLayout()
layout.mediaFileURL = self.videoURL
message.layout = layout
But, when I call the insertMessage
method, I can't get the correct message entity (no video included)
conversation.insertMessage(message, completionHandler: nil)
I've read somewhere (not an official source) that the URL should be a local URL, is that true?
Thanks in advance for any help
ADDING
I'm even trying to download the content and set the local URL, but I'm having the same behavior
This is the quick implementation I tried
let fileURL = storeDirectory.URLByAppendingPathComponent("video-file.mov")!
_ = try? NSFileManager.defaultManager().removeItemAtPath(fileURL.path!)
Alamofire.download(.GET, self.videoURL) { _, _ -> NSURL in
return fileURL
}.response { _, _, _, error in
print("Error: \(error)")
layout.mediaFileURL = fileURL
print("File URL: \(fileURL)")
message.layout = layout
completion(.success(message))
}
Of course, the error is nil
and the file path is a valid local path that references a valid video file (I can reproduce it by going at that path)
SOLVED:
For anyone is experiencing this problem, please make sure to download the media file firstly. It's not mentioned in the documentation, but it's mandatory. Then, even if in the documentation the audio file is mentioned, a normal mp3 file doesn't work at all. Still don't know what's the specification regarding the audio file.
After that, make sure your result is fine: sending the media file in the MSMessageLayout
means that it's muted and you've to handle the detail view when it's tapped. Consider to use the insertAttachment
method of MSConversation
instead.