Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using CFBundleDocumentTypes: why does my app not show up in the "Share" menu?

I'm trying to register my app for all possible file types. I added the following to my info.plist:

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

If I now open a PDF in Safari and tap Safari's "Share" button, my app is not offered. However if I tap the PDF itself, a button "Open In" appears on top and there my app is listed.

This is not a real problem but it prevents users to import photos into my app, because there is no "Open In" menu in the Photos app.

Can I register for the "Share" menu too somehow?

like image 342
Krumelur Avatar asked Feb 21 '14 14:02

Krumelur


1 Answers

Unfortunately this is not possible, because:

The share screen in Safari is using UIActivityViewController to display a number of activities that can be performed with the page. Those activities are defined in UIActivity.h and are usually the system-defined activities such as Post to Facebook, Post to Twitter, Message, Print, etc.

For an non-system defined activity to appear in that screen, one has to create a custom UIActivity subclass and then initialize the UIActivityViewController with an array of these.

The "Open In..." screen on the other hand looks similar but is using a UIDocumentInteractionController which displays apps that can open the given URL/UTI (don't Google UTI...)

like image 172
Mark Gaensicke Avatar answered Nov 12 '22 17:11

Mark Gaensicke