简体   繁体   中英

Open a GPX file in my iPhone app, from Safari

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM