1

I am trying to make an app that will receive media files from the Mail app by using Long Press > Open in "My app"

I am having trouble associating the files types I want with my app. I am using the Uniform Type Identifiers Reference

This is what my info.plist looks like:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>mp3</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>MP3 Audio</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.mp3</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>avi</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>AVI movie</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.avi</string>
            <string>video/x-msvideo</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>3gp</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>3GPP movie</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.3gpp</string>
            <string>application/octet-stream</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>mpg4</string>
            <string>mp4</string>
            <string>m4v</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>MPEG-4 content</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.mpeg-4</string>
            <string>video/mp4</string>
            <string>video/mp4v</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>mov</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>QuickTime movie</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.apple.quicktime-movie</string>
            <string>video/quicktime</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
</array>

Out of these, only Mp3 and AVI show the Open In "My app" option. I just get the "Save Video" option that adds the videos to my camera roll. What am I doing wrong?

The formats I want to associate are: AVI, 3GP, MP4, M4V, MOV.

I have also tried this. It works for MP3, WAV, AVI, FLV but still no go for 3GP, MP4, MOV, M4V

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>Audio</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.audio</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeName</key>
        <string>Video</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.movie</string>
        </array>
    </dict>
</array>
Vaibhav Garg
  • 3,630
  • 3
  • 33
  • 55

2 Answers2

3

SO answer to How do I associate file types with an iPhone application?, shows some examples that differ from yours only very slightly. the content of this file looks like it should work, though there are some redundancies according to the documentation:

  • CFBundleTypeExtensions is MacOS only, and even then, it is redundant and ignored if LSItemContentTypes is present.
  • LSTypeIsPackage is MacOS only, and even then, it is redundant and ignored if LSItemContentTypes is present.
  • the documentation recommends using a uniform type identifier for CFBundleTypeName . e.g. for mp4, rather than use MPEG-4 content as you have, instead, try public.mpeg-4 (internally kUTTypeMPEG4)

still, while i think the cleanup would be a good idea, i think only the last one of these may have a real chance of solving your problem, because the other two should just get ignored.

… which means what i think may actually solve your problem is cleaning your app off the device and out of your cache, quitting xcode, and then re-opening your project, re-building, and running it again. i have experienced problems where Xcode and its deployment mechanism get confused when putting resources on the device. performing this cleanup may straighten things out if some attempt at registration initially failed before you got to this point.

Community
  • 1
  • 1
john.k.doe
  • 7,533
  • 2
  • 37
  • 64
  • I have tried your ideas but it doesnt work. I dont get the Open In "My App" option in the Mail app.I used: CFBundleTypeName mp4 CFBundleTypeRole Viewer LSItemContentTypes public.mpeg-4 – Vaibhav Garg Jul 22 '12 at 11:12
  • one of the other posts showed CFBundleTypeNamepublic.mpeg-4 for that bit of the definition. my reading is that isn't required, and i've seen other examples set up like yours, but as in the last bullet, this name may be required in that slot. – john.k.doe Jul 22 '12 at 16:59
  • :( still Doesnt work: CFBundleTypeName public.mpeg-4 CFBundleTypeRole Viewer LSHandlerRank Alternate LSItemContentTypes public.mpeg-4 .. I have tried on two phones and two macs! – Vaibhav Garg Jul 23 '12 at 07:55
  • more things to try: i see at https://bitbucket.org/1951FDG/mplayer/src/09def39b7359/Info.plist and at http://cydia.ovihost.com/debs/iFile/Applications/iFile.app/Info.plist examples of Info.plist files that seem to conform to you have at this point (the first is a mac package, so has the LSTypeIsPackage; both show the public.3gpp style names in LSItemContentType, which you have). they both do make a reference to a different protected apple mpeg-4 format, but that wouldn't explain why 3gpp is not working for you. anyway, maybe those URLs will help highlight a difference with what you have … – john.k.doe Jul 23 '12 at 08:21
  • i have installed other apps that also support media importing.. they too dont show up in the "Open As .." actionsheet for the Mail app. I am guessing that apple doesnt allow some files to be exported. so one has to save them to Camera Roll. So the only options that remains is to add functionality to the app itself to allow selecting videos from the camera roll. What a bummer. – Vaibhav Garg Jul 23 '12 at 09:34
0

I have installed other apps (e.g TeamViewer, oPlayer etc) that also support Document importing.. They too dont show up in the "Open As .." Action Sheet for the Mail app for MOV, 3GP, M4V etc.

I am guessing that apple doesnt allow some files to be opened by 3rd party apps and wants them handled internally. So all the user can do is save them to the Camera Roll.

The only options that remains is to add functionality to our apps to allow selecting videos from the camera roll. So, Mail > Save Video > Camera Roll > 3rd Party App

What a bummer.

My Final entries in Info.plist

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>Audio</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.audio</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeName</key>
        <string>Video</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.3gpp</string>
            <string>public.3gpp2</string>
            <string>public.mpeg-4</string>
            <string>public.avi</string>
            <string>com.apple.quicktime-movie</string>
            <string>public.mpeg</string>
            <string>public.movie</string>
        </array>
    </dict>
</array>

I am still hoping there is some way around this.. anyone?

Vaibhav Garg
  • 3,630
  • 3
  • 33
  • 55