As we know with the launch of ios 8 the apple allow custom Keyboard extension.In keyboard extension we can send images,gif etc in SMS by using Copy image to clipboard.code
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSData *data= UIImagePNGRepresentation([UIImage imageNamed:@"so_close_disappointed_meme.png"]);
[pasteboard setData:data forPasteboardType:@"public.png"];
Now i am trying to send audio file in iMessage like this feature reference.don't know apple will allow us to send audio in iMessage?.so for i tried above approach but it did not show any paste option for audio in SMS window.
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *path = [[NSBundle mainBundle] pathForResource:@"tune"ofType:@"mp3"];
NSURL *url = [[NSURL alloc] initWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
[pasteboard setData:data forPasteboardType:@"public.mp3"];
Any one can suggest me how do we send audio file by using custom keyboard extension.is it possible?
Sending an audio file via iMessage To send an audio file using the iMessage service, tap on the entry containing its name, and, in the newly opened panel, select the Share icon 1. From the available file sending options, select Message 2.
Audio messages are a convenient and quick way to talk with your contacts, using audio recordings sent as part of your iMessage conversations. So rather than typing out or reading a message, you can instead record your message and listen to audio messages from others.
To send a voice recording in a text message using your Android-operated phone, follow this procedure: Go to 'Messages' and select your recipient. Click and hold the 'Recording' icon (at the bottom right of the screen) while recording your message. Click the arrow icon (also at the bottom right) to send your audio file.
I believe you could directly attach the file to MFMessageComposeViewController
. Here is the documentation link of how it could be done.
Following would be the steps to do so.
+
(BOOL)isSupportedAttachmentUTI:(NSString *)uti
MFMessageComposeViewController
using -
(BOOL)addAttachmentData:(NSData *)attachmentData
typeIdentifier:(NSString *)uti filename:(NSString *)filename
As the description for the method says
This method is especially useful when the attachment you want to add to a message does not have a file system representation. This can be the case, for example, for programmatically composed audiovisual content.
Note : You will have to convert audio file to NSData
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With