How to associate iPhone application with _every_ file type?

前端 未结 3 1463
天命终不由人
天命终不由人 2021-02-13 02:41

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 extens

相关标签:
3条回答
  • 2021-02-13 02:53

    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.

    0 讨论(0)
  • 2021-02-13 03:15

    An idea for investigation...

    If the installation of another app "fixes" the problem then try inspecting the other apps Info.plist file to see if it is registering or exporting any interesting UTIs or similar settings.

    It sounds like your app might only be doing half the job and the other app is completing the missing setup.

    You can inspect the contents of an apps ipa file from iTunes by copying it, renaming ipa to zip extracting the contents and then Show Package Contents on the app inside.

    0 讨论(0)
  • 2021-02-13 03:16

    Friend, I read your question properly before posting the answer. I gave another thought that you will have a set of already known "any types" of files to register in a bulk. However, you want to dynamically accommodate your app to register any file type given to your app in future and make it attachable. For this as far as my knowledge is concerned, you cannot make you app to universally support any unknown file type. Let me explain what happens,

    1. Suppose you make an application APP1 then it does not know about a file extension .XYZ and install it on iPhone.

    2. But, later I develop another application APP2, which contains the above code and I register the .XYZ type from APP2 in whatever iPhone it installs.

    3. So, lets say I install APP2 in your iPhone, having APP1. And when my app runs, then the .XYZ extension ( known to APP2 ahead of time) gets registered into the iPhone.

    This is the reason now your app APP1 can use this .XYZ file surprisingly.

    Concluding, you have to know a specific type of extensions ahead of time before making the app.

    However, heres a possible solution for it.

    Solution :

    1. Decide the maximum number of characters you want to support in an extenstion. Lets say 4.

    2. Now you can make a small Brute-Force routine to run in your app to make all the possible character combinations and register them all. This should make any file with extension upto 4 characters attachable to mail.

    I hope that should do the trick.

    Best of luck!

    0 讨论(0)
提交回复
热议问题