从 Safari 在我的 iPhone 应用程序中打开 GPX 文件

发布于 2025-01-02 13:38:26 字数 2064 浏览 1 评论 0原文

我希望用户能够单击 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈下烟灰 2025-01-09 13:38:26

肯定需要更新的一件事是:

<key>public.filename-extension</key>
<string>gpx</string>

应该

<key>public.filename-extension</key>
<array>
    <string>gpx</string>
</array>

根据 https://developer.apple.com/library/prerelease/ios/qa/qa1587/_index.html

One thing that definitely needs update is:

<key>public.filename-extension</key>
<string>gpx</string>

should be

<key>public.filename-extension</key>
<array>
    <string>gpx</string>
</array>

according to the Troubleshooting Tips from https://developer.apple.com/library/prerelease/ios/qa/qa1587/_index.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文