3

我正在开发一个具有文件扩展名的 iOS 应用程序,例如.vlin,我希望 iOS 设备能够识别这个扩展名。到目前为止,我能够实现以下目标

  • .vliniphone本机邮件客户端支持
  • 单击.vlin文件在我的应用程序中打开Vlin

我正在使用 cordova 并在 config.xml 中添加了配置设置

但不知何故,它不适用于 iOS Safari 浏览器。如果我尝试在 iOS Safari 中打开文件,它会在浏览器本身中作为文本文件打开。我希望它在我的VliniOS 应用程序中打开。

我的 info.plist 和 config.xml 代码是:

<platform name="ios">        
<preference name="IosLaunchMode" value="singleTask" />
<config-file platform="ios" target="*-Info.plist" parent="UIFileSharingEnabled">
    <true />
</config-file> 
<config-file platform="ios" target="*-Info.plist" parent="CFBundleDocumentTypes">
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>com.example.vlin.vlin</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.example.vlin.vlin</string>
            </array>
        </dict>
    </array>
</config-file>
<config-file platform="ios" target="*-Info.plist" parent="UTExportedTypeDeclarations">
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.data</string>
            </array>
            <key>UTTypeDescription</key>
            <string>Vlin document</string>
            <key>UTTypeIdentifier</key>
            <string>com.example.vlin.vlin</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <string>vlin</string>
            </dict>
        </dict>
    </array>  
</config-file>

非常感谢任何帮助,在此先感谢。

  • 信息列表

        <key>UIFileSharingEnabled</key>
        <true/>
        <key>CFBundleDocumentTypes</key>
        <array>
          <dict>
            <key>CFBundleTypeName</key>
            <string>com.example.vlin.vlin</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
              <string>com.example.vlin.vlin</string>
            </array>
          </dict>
        </array>
        <key>UTExportedTypeDeclarations</key>
        <array>
          <dict>
            <key>UTTypeConformsTo</key>
            <array>
              <string>public.data</string>
            </array>
            <key>UTTypeDescription</key>
            <string>Vlin document</string>
            <key>UTTypeIdentifier</key>
            <string>com.example.vlin.vlin</string>
            <key>UTTypeTagSpecification</key>
            <dict>
              <key>public.filename-extension</key>
              <string>vlin</string>
            </dict>
          </dict>
        </array>
      </dict>
    

样本文件格式:invite.vlin

{
 "invite”: {
  "name": “Some College",
  "identifier": “xxxxxxxxxxxxxxxxx”
 },
 “value”: “xxxxxxxxxxxxxx”
}
4

1 回答 1

0

编辑2:

您真正的问题是 safari 将您的 .vlin 文件视为文本文件,并且不会为您提供在另一个应用程序中打开它的选项,也许如果您正确配置服务器以将其作为com.example.vlin.vlin或者可能application/json应该向您显示打开带对话框。

例如,您可以在我的服务器上测试这个 .vlin 文件。

http://jcesarmobile.byethost33.com/test4.vlin

这不是一个真正的 .vlin 文件,它是一个压缩并重命名为 .vlin 的 .vlin 文件,并且 safari 显示打开对话框

编辑:

不知道为什么人们不赞成,来自 config.xml 的配置文件标签未实现,请参阅实现它的问题

原答案:

您还不能在 config.xml 中使用 config-file 标记(它正在处理中,但尚未完成)。

您可以在 plugin.xml 上使用它,因此您必须创建一个“哑”插件,其中只有带有这些标签的 plugin.xml。

您可以查看这个仅使用 plugin.xml 写入 Info.plist 的插件 https://github.com/leecrossley/cordova-plugin-transport-security

于 2016-10-07T11:00:01.417 回答