D34thSt4lker
D34thSt4lker

Reputation: 447

iOS 8 Keyboard Extension : How to copy/paste an audio or video clip into messages?

I am working with the new keyboard extensions and I am able to create a keyboard to allow text to be sent through. (The easy stuff). I also figured out how to copy+paste images within the keyboard extension into the messages. However I cannot seem to find much or any information on how I can send an audio clip to someone through messages (or a video file).

I understand this has to be similar to the way sending images works. Where you need to copy and paste it into the field.

Does anyone know how to get this done? Thanks!

Upvotes: 4

Views: 518

Answers (1)

Peter Argany
Peter Argany

Reputation: 56

The process to get an audio clip to the pasteboard should be pretty similar to an image. Here's some swift code which pastes a file called audio.wav

let path = NSBundle.mainBundle().pathForResource("audio", ofType:"wav")
let fileURL = NSURL(fileURLWithPath: path!)
let data = NSData(contentsOfURL: fileURL)
let wavUTI = "com.microsoft.waveform-audio"
UIPasteboard.generalPasteboard().setData(data!, forPasteboardType: wavUTI)

Upvotes: 4

Related Questions