Associating my app's custom file in iOS

青春壹個敷衍的年華 提交于 2019-12-01 00:25:36

If your UTI is declared as public.data I assume that your checklist file is a custom binary data.

You should then simply use application/octet-stream as a mime-type.

UPDATE: Got it, your problem is more trivial than anyone would expect. One more thing for starters - public.data is okay for all its descendants (including public.xml), so for an XML file you can set any of these:

  • public.item
  • public.data
  • public.content
  • public.text
  • public.xml

The list of applications offered to open your file type is build based on known apps in system that can handle given UTI plus yours. Since the default text editor opens public.text and public.xml it will be the default action for your kind of files (your application will show up on the list invoked by a long press on a mail attachment).

There is (apparently) no applications that handle public.data (the same for public.content), so when you use this UTI, the default action for an attachment would be to open it in your app.

Now to the point... your CFBundleDocumentTypes has one extra <array> level:

<key>CFBundleDocumentTypes</key>
<array>
    <array>     <!-- remove this line -->
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array>
                <string>docIcon64.png</string>
                <string>docIcon320.png</string>
            </array>
            <key>CFBundleTypeName</key>
            <string>My App Checklist</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.mycompany.appid.checklist</string>
            </array>
        </dict>
    </array>     <!-- and this line -->
</array>

And it's gonna work. The UTExportedTypeDeclarations part is already fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!