使用iOS SDK中的短信/彩信发送附件 [英] Send attachments using sms/mms in iOS SDK
问题描述
在iOS 7中,支持通过第三方应用程序在短信中添加附件.
In iOS 7, there is support for adding attachments in sms messages via third party applications.
我想知道:
-
支持哪些文件作为附件?例如.png,.pdf等.
What kind of files are supported as attachments? e.g. .png, .pdf etc.
我可以通过短信/彩信发送NSData吗?例如.dat格式
Can I send NSData through an sms/mms message? e.g. .dat format
这些邮件的收件人能否使用iOS的打开方式"功能在第三方应用程序中打开这些附件?
Would the recipient of these messages be able to open these attachments in third party applications using iOS's "Open In" feature?
推荐答案
MFMessageComposeViewController
希望附件具有您要上传的图像类型的正确扩展名.
我通过测试PNG
文件以及添加附件数据的以下变体进行了验证:
The MFMessageComposeViewController
wants the attachment to have the correct extension for the type of image you're uploading.
I verified by testing with a PNG
file, and the following variations of adding the attachment data:
[messageController addAttachmentData:imgData typeIdentifier:@"public.data" filename:@"image"];
[messageController addAttachmentData:imgData typeIdentifier:@"public.data" filename:@"image.abc"];
[messageController addAttachmentData:imgData typeIdentifier:@"public.data" filename:@"image.png"];
仅最后一个选项有效.
我不需要更改typeIdentifier
,尽管选择与数据类型匹配的UTI可能很有意义.
Only the last option worked.
I didn't need to change the typeIdentifier
, although it probably would make sense to choose a UTI that matches the type of data.
这篇关于使用iOS SDK中的短信/彩信发送附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!