如何发送音频文件,通过IOS的iMessage发送8 [英] How do I send audio file send via iMessage ios 8
问题描述
据我们所知,推出iOS 8的苹果允许自定义键盘extension.In键盘的扩展,我们可以通过将图片复制到剪贴板发送图像,GIF等短信。的code
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"];
现在我试图发送音频文件中的iMessage喜欢这个功能参考 .don't知道苹果将允许我们在的iMessage发送音频?是.so因为我尝试了上述做法,但它并没有显示在短信界面音频任何粘贴选项。
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"];
任何一个可以建议我,我们如何通过使用自定义键盘extension.is可以发送音频文件?
Any one can suggest me how do we send audio file by using custom keyboard extension.is it possible?
推荐答案
我相信你可以直接连接该文件 MFMessageComposeViewController
。这里是<一个href=\"https://developer.apple.com/library/$p$prelease/ios/documentation/MessageUI/Reference/MFMessageComposeViewController_class/index.html#//apple_ref/occ/instm/MFMessageComposeViewController/addAttachmentData:typeIdentifier:filename:\">documentation它如何做链接。
I believe you could directly attach the file to MFMessageComposeViewController
. Here is the documentation link of how it could be done.
以下是这样做的步骤。
- 检查文件可以使用文件UTI使用
发送+
(BOOL)isSupportedAttachmentUTI:(* NSString的)UTI - 找到文件UTI。即,对于文件路径
- 附加文件
MFMessageComposeViewController
使用-
(BOOL)addAttachmentData:(NSData的*)attachmentData
typeIdentifier:(* NSString的)尿路感染的文件名:(* NSString的)文件名
- Check if file can be send using file UTI using
+ (BOOL)isSupportedAttachmentUTI:(NSString *)uti
- Find File UTI. i.e. path for the file
- Attach file to
MFMessageComposeViewController
using- (BOOL)addAttachmentData:(NSData *)attachmentData typeIdentifier:(NSString *)uti filename:(NSString *)filename
对于方法的介绍称
当附件要添加到消息不具有文件系统重新presentation这种方法是特别有用的。这可以是这种情况,例如,以编程组成视听内容。
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.
请注意:您将有音频文件转换为NSData的
Note : You will have to convert audio file to NSData
这篇关于如何发送音频文件,通过IOS的iMessage发送8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!