从 Safari 在我的 iPhone 应用程序中打开 GPX 文件
我希望用户能够单击 Safari 中的 GPX 文件链接,并将它们导入到我的应用程序中。
我有这样的工作 - 我可以访问一些网站,单击 GPX 文件,它会给我在我的应用程序中打开的选项。
但是,某些 GPX 文件(包括我在本地计算机上托管的简单 GPX 文件)无法以这种方式打开。我在注册 GPX 文件类型时可能做错了什么?
这是我的 plist 代码:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>GPSXML File</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>CFBundleTypeIconFile</key>
<string>gaia-icon.png</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>public.utf8-plain-text</string>
<string>com.apple.dt.document.gpx</string>
<string>com.trailbehind.gpx</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.trailbehind.gpx</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.mime-type</key>
<string>text/plain; charset=UTF-8</string>
<key>public.filename-extension</key>
<string>gpx</string>
</dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.content</string>
<string>public.item</string>
<string>public.data</string>
<string>public.xml</string>
<string>public.text</string>
</array>
<key>UTTypeDescription</key>
<string>GPSXML</string>
</dict>
</array>
<key>UIFileSharingEnabled</key>
<true/>
I would like users to be able to click links in Safari that are GPX files, and import them into my app.
I have this sort of working - there are some websites I can go to, click a GPX file, and it will give me the option to open in my app.
However, some GPX files, including a simple GPX file that I am hosting on my local machine, won't open in this way. What might I have done wrong in registering for the GPX file type?
Here is my plist code:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>GPSXML File</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>CFBundleTypeIconFile</key>
<string>gaia-icon.png</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>public.utf8-plain-text</string>
<string>com.apple.dt.document.gpx</string>
<string>com.trailbehind.gpx</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.trailbehind.gpx</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.mime-type</key>
<string>text/plain; charset=UTF-8</string>
<key>public.filename-extension</key>
<string>gpx</string>
</dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.content</string>
<string>public.item</string>
<string>public.data</string>
<string>public.xml</string>
<string>public.text</string>
</array>
<key>UTTypeDescription</key>
<string>GPSXML</string>
</dict>
</array>
<key>UIFileSharingEnabled</key>
<true/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
肯定需要更新的一件事是:
应该
根据 https://developer.apple.com/library/prerelease/ios/qa/qa1587/_index.html
One thing that definitely needs update is:
should be
according to the Troubleshooting Tips from https://developer.apple.com/library/prerelease/ios/qa/qa1587/_index.html