Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Registering GPX (or XML) file to open in iOS app

Tags:

I am having trouble opening GPX files in my iOS app. I registered the extension and some files open correctly, that is when I tap on a link to GPX file in Safari, it shows a prompt asking me which application I want to use to open the file. Then I select my application and the file is processed as expected. With some websites in Safari and with all files from email attachments, the prompt and app selection is not displayed and the browser/email app shows contents of the file as text.

I suspect this is problem with the info.plist settings or possibly with the Safari and email apps. If you open XML or GPX files in your ios apps correctly, would you post your CFBundleDocumentTypes and UTExportedTypeDeclarations settings from info.plist?

Any thoughts are welcome. Here is the appropriate section from my info.plist. I tried to add and remove some optional tags, this is the latest, but not most complete.

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>Icon.png</string>
            <string>[email protected]</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>GPS eXchange Format</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>org.elsners.Indicium.gpx</string>
        </array>
    </dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.xml</string>
        </array>
        <key>UTTypeDescription</key>
        <string>GPS eXchange Format</string>
        <key>UTTypeIdentifier</key>
        <string>org.elsners.Indicium.gpx</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>GPX</string>
                <string>gpx</string>
            </array>
        </dict>
    </dict>
</array>
like image 283
MirekE Avatar asked May 07 '12 14:05

MirekE


1 Answers

When working with HTTP content (which is the case of Safari and Mail app), you must not forget to handle its content type. The Uniform Type Identifier (UTI) for handle content type is public.mime-type and let's say that the content type header of a server response is set to application/gpx, so in your plist you must add to the UTTypeTagSpecification section:

<dict>
  <key>public.filename-extension</key>
   <array>
     <string>GPX</string>
     <string>gpx</string>
   </array>
   <key>public.mime-type</key>
   <string>application/gpx</string>
</dict>

Note: I've seen application/gpx and application/gpx+xml as content type for GPX data around web and I don't know if there's a standard mime type so it's better to use both.

like image 76
Wallace Campos Avatar answered Nov 10 '22 15:11

Wallace Campos