【发布时间】:2014-05-14 15:39:56
【问题描述】:
在我的应用程序中,我需要将一些自定义数据文件从一台设备发送到另一台设备,我正在尝试使用 Mail、iMessage/Message 和 Airdrop 来做到这一点。
这适用于 Mail 和 Airdrop,但适用于 iMessage,它运行良好,但在接收端,我无法打开文件。它只是不允许我用它做任何事情。
有什么想法吗??
这是我的文档类型的样子:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFile</key>
<string>abc.png</string>
<key>CFBundleTypeName</key>
<string>ABC Custom Data type</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>Handler Rank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.company.abc.wd</string>
</array>
</dict>
</array>
这就是我发送数据的方式:
NSMutableDictionary * dict = [NSMutableDictionary dictionary];
[dict setObject:currentDataSet forKey:@"actualData"];
NSData * meetingData = [NSKeyedArchiver archivedDataWithRootObject:dict];
Meeting * dataItem = [[Meeting alloc]initWithData:meetingData
type:@"com.abc.xyz.wd" subject:@"Meeting"
previewImage:[UIImage imageNamed:@"appIcon.png"]];
UIActivityViewController * activityController =
[[UIActivityViewController alloc]initWithActivityItems:@[dataItem]
applicationActivities:nil];
activityController.excludedActivityTypes =
@[UIActivityTypePostToTwitter, UIActivityTypePostToWeibo];
[self presentViewController:activityController animated:YES completion:nil];
【问题讨论】:
-
不确定您是否必须坚持标准 UTI - developer.apple.com/library/ios/documentation/Miscellaneous/… - 您是否有代码示例说明您在将文件附加到消息时尝试执行的操作,您是否使用
addAttachmentData:typeIdentifier:filename:? -
您只想发送 PNG 文件吗?如果不是,您可以使用以下代码发送/检测各种格式
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array/> <key>CFBundleTypeName</key> <string>com.jungleDisk.file</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>public.data</string> </array> </dict> </array> -
@Ashutosh,你有想过这个吗?我遇到了同样的问题并遇到了这个线程。
标签: ios objective-c ios7 imessage