How can I make my app appear in UIActivityViewController for text?
Asked Answered
D

2

7

I would like my app to appear in the UIActivityViewController for text, in other apps. For example, when sharing from the Notes app as shown below.

enter image description here

Adding the following to the Info.plist didn't produce any visible results (in Notes, Evernote and Simplenote):

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>icon-text-57.png</string>
            <string>icon-text-72.png</string>
            <string>icon-text-114.png</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>Text</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.text</string>
            <string>public.plain-text</string>
            <string>public.utf8-plain-text</string>
            <string>public.utf16-external-plain-​text</string>
            <string>public.utf16-plain-text</string>
            <string>public.rtf</string>
        </array>
    </dict>
</array>

Is this possible? How?

Doordie answered 10/2, 2014 at 20:23 Comment(0)
D
8

Short answer: you can't.

Currently, you cannot add your app into other UIActivityViewControllers, unless you create your own UTI and the app ( Notes, Evernote and Simplenote) add code into their app to show yours.

What you are likely referring to, though, is the UIDocumentInteractionController, which is different, and there you CAN add your app, and I believe you are doing that correctly.

The things you are trying are all UIActivityViewControllers so no matter how hard you try, your app will not show up there.

Quick note to add: A good way to distinguish between is UIActivityViewControllers and a UIDocumentInteractionController is to see if "Dropbox" comes up in it. From my experience the Dropbox app has a "catch-all" UTI and can take any file so it usually comes up in nearly all UIDocumentInteractionController's. Of course, you'll need to have the app installed

Dugas answered 12/2, 2014 at 21:10 Comment(2)
Is this still true? Maybe I'm misunderstanding your answer, but I see "Save to Dropbox" in a plain UIActivityViewController, on the second row of icons. I'd like my app to appear alongside it, and it does with a UIDocumentInteractionController, but not alongside Dropbox in a UIActivityViewController.Retrogradation
@TimCamber Good point. This info is outdated as of iOS 8, where Share Extensions were added and is the correct way. I'll update the answer.Dugas
R
1

You're plist is wrong, see this answer: Why is my iOS app not showing up in other apps' "Open in" dialog? but to me it looks like you haven't yet set the LSHandlerRankin your plist.

Also: make sure you follow Apple's own Documentation: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html

Resolvable answered 10/2, 2014 at 20:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.