Blakedallen Blakedallen - 1 year ago 60
Swift Question

Sending an animated Gif via sms in Swift

I'm trying to send an animated gif via the MFMessageComposeViewController in swift,

It seems to be working fine when I send the gif, however the preview shows a non-moving image. Any thoughts on how to make the preview animated?

let messageComposeVC = MFMessageComposeViewController()
let imgData = NSData(contentsOfURL: NSURL(string: "http://dramallamaapp.com/wp-content/uploads/2016/08/output_9GECbQ.gif")!)
if imgData != nil {
messageComposeVC.addAttachmentData(imgData!, typeIdentifier: "com.compuserve.gif", filename: "animated.gif")
}
messageComposeVC.messageComposeDelegate = self
presentViewController(messageComposeVC, animated: true, completion: nil)

Answer Source

Upon further investigation, I now believe this is default iOS behavior, as with iMessages the same happens (gif shows as an image until sent, then begins animating).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download