Question

I am working on an iOS application that allows exporting its data by emailing a file. The app registers the file-type as a file having the extension 'sainputs' (this is so that the app can also open a file from an email or dropbox for importing the values - this works fine). I am trying to add the possibility to send the file to any other application that can open miscellaneous types of files. Dropbox is a good example - it is supposed to be able to open any type of file.

I am currently attempting this by displaying a UIDocumentInteractionController that is initialized with the URL of the file. When it is displayed, the Dropbox app appears as one of the available choices for opening the file, as expected.

However, when I press the Dropbox icon, nothing happens and in the console I see the following text:

LaunchServices: Invalid LSOpenOperation request - No applications found to open document

In the app's plist file it registers a document type having UTI com.mycompany.myapp.sainputs, and it registers an exported type UTI having identifier com.mycompany.myapp.sainputs, with public file name extension 'sainputs' and MIME-type myapp/inputs.

Here are the relevant excerpts from the plist file:

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>My App's File Type</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.mycompany.myapp.sainputs</string>
            </array>
        </dict>
        <array>
.
.
.
<key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array/>
            <key>UTTypeDescription</key>
            <string>My App's File Type</string>
            <key>UTTypeIdentifier</key>
            <string>com.mycompany.myapp.sainputs</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <string>sainputs</string>
                <key>public.mime-type</key>
                <string>steuerapp/inputs</string>
            </dict>
        </dict>
        <array>

I tried changing the MIME-type to 'application/octet-stream' in the plist file. It did not make a difference.

Any advice/ideas would be highly appreciated.

Was it helpful?

Solution

As @maddy suggested and @bgh confirmed, this solves the issue. I just ran into the same problem.

Besides defining your custom Universal Type you can also hint that this type is a 'subtype' of a more general type. E.g. by explicitly specifying the UTI 'public.data' in the key UTTypeConformsTo as follows:

<dict>
   <key>UTTypeConformsTo</key>
      <array>
         <string>public.data</string>
      </array>
   <key>UTTypeDescription</key>
      <string>My App's File Type</string>
   <key>UTTypeIdentifier</key>
      <string>com.mycompany.myapp.sainputs</string>
   <key>UTTypeTagSpecification</key>
      <dict>
        <key>public.filename-extension</key>
           <string>sainputs</string>
        <key>public.mime-type</key>
           <string>steuerapp/inputs</string>
      </dict>
</dict>

You can then specify your custom uti as an argument in the UIDocumentInteractionController:

UIDocumentInteractionController *documentController = ...;
documentController.UTI = @"com.mycompany.myapp.sainputs";

Apples documentation about this can be found here.

OTHER TIPS

In case this happen to someone else :

i couldn't make Klaas answer work because i had another app on the device (the "light" version) also declaring the same UTI, with incorrect settings. You need to add "public.data" in every app that declares the type before it can work.

Just to make sure, i would recommend debugging with only one app installed, then add the other one and see if everything still works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top