Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to associate iPhone application with _every_ file type?

There is iPhone app "Another Mail Client" that should be able to open any file to send it as attachment. So, I want to associate this application with any file with any extension.

Following the documentation, we should declare support for files with the root UTI-type public.data – any file should belong to this type. It works, but not at all. In this case, our app will not be able to open any file, but only those which have already been registered in the system. For example, if in any application (e.g., dropbox) we'll try to "open in..." file with an unknown extension (file.unknowntype) using UIDocumentInteractionController, then the answer will be negative despite the fact that we have already registered our application and it supports the root UTI-type public.data. But, if you install another application, which supports files with extension (*.unknowntype), then our application will also be able to open these files and will appear in "open in..." application list.

UPD: @Gabriel This is CFBundleDocumentTypes part of my info.plist file:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>MyMail</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.data</string>
        </array>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Default</string>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>Icon29.png</string>
            ...
            <string>Icon114.png</string>
        </array>
    </dict>
</array>
like image 877
ddnv Avatar asked Feb 20 '12 14:02

ddnv


People also ask

How do I change file associations on my iPhone?

Question: Q: Changing File Associations Answer: A: Answer: A: Select a file in the Finder, choose Get Info from the File menu, pick the desired application under Open With, click on Change All, and confirm this action.

How do I associate a file type with an app?

Open File Manager and browse the the folder containing the files that you want to associate with a particular app. This will set the target file types to be opened with the selected app and open that file in that app as well. By the way doing things in Android is not too difficult.

How do I reset associate file types with specific apps?

Go to Apps > Default apps. Click the Choose defaults by file type option. Select a file type or extension. Choose an app you want to set as default.


1 Answers

I've made an app with the following setup

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array/>
        <key>CFBundleTypeName</key>
        <string>name</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.data</string>
        </array>
    </dict>
</array>

When I try to open a .pdf from Safari, this app shows up in "open in.." list. Can you make a sample app and try it?

UPD:

It seems like claim 'public.data' (tried also public.item, public.content) means file, which belongs to set "all known to system UTIs", not any file. So, you will be able to handle 99% of files, which users want to send by email , but not all. Another way would be to export UTI that you think are important, but which are not in system UTIs by default.

like image 75
fspirit Avatar answered Sep 20 '22 23:09

fspirit