本文介绍了自定义扩展文件未在iMessage中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我需要将一些自定义数据文件从一个设备发送到另一个设备,我正在尝试使用Mail,iMessage / Message和Airdrop执行此操作。

In my app, I need to send some custom data files from one device to another, and I am trying to do this with Mail, iMessage/Message and Airdrop.

这适用于Mail和Airdrop,但是使用iMessage并且它很好,但在接收端,我无法打开文件。它只是不允许我用它做任何事情。

This works fine with Mail and Airdrop but with iMessage and it goes just fine, but on the receiving end, I am not able to open the files. It's just not allowing me to do anything with it.

任何想法?

这就是我的文档类型:

<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>

这就是我发送数据的方式:

This is how i am sending the data:

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];


推荐答案

我在搜索类似解决方案时遇到过这篇文章。我能够从我的应用程序发送自定义文件,然后通过电子邮件打开或与AirDrop一起使用。如果我通过iMe​​ssage发送它,它甚至出现了我的自定义图标,但是当我在iMessage中点击它时没有发生任何事情。

I came across this post while searching for a similar solution. I was able to email custom files from my app and open it in email or use it with AirDrop. If I sent it via iMessage it even showed up with my custom icon, but when I tapped it in iMessage nothing happened.

请注意,您需要类似以下内容您的plist文件(来自)

Be aware that you need something like the following in your plist file (from How do I associate file types with an iPhone application?)

<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
    <array>
        <string>public.plain-text</string>
        <string>public.text</string>
    </array>
    <key>UTTypeDescription</key>
    <string>Molecules Structure File</string>
    <key>UTTypeIdentifier</key>
    <string>com.sunsetlakesoftware.molecules.pdb</string>
    <key>UTTypeTagSpecification</key>
    <dict>
        <key>public.filename-extension</key>
        <string>pdb</string>
        <key>public.mime-type</key>
        <string>chemical/x-pdb</string>
    </dict>
</dict>

注意:我有一些非常的东西类似于我的应用程序但在UTTypeConformsTo我只有public.data,因为我的文件是压缩数据文件。

NOTE: I had something very similar for my app BUT in the UTTypeConformsTo I only had public.data since my files are zipped data files.

我发现通过添加public.text作为第二项它可以在iMessage中操作的数组。另外请注意,如果我将public.plain-text添加为第三项,我的文件最终会显示一个Pages图标而不是我的图标(所以我删除了它)

I found that by adding public.text as a second item in the array it would be actionable in iMessage. On a further note, if I added public.plain-text as a third item my file ended up with a Pages icon instead of my icon (so I removed it)

我希望这可以帮助别人。我花了几个小时才到达底部。

I hope this helps someone. It's taken me hours to get to the bottom of it.

这篇关于自定义扩展文件未在iMessage中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 18:11