I am familiar with the share functionality on IOS. I share items in my app using
[[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
My question is how do I add an open with option to the share sheet of my app ?
The "Open in…" options are made available based on the content that's being opened and the document types supported by the device's installed apps. It's not something you can alter from your app.
On the other hand, if the apps that you want to appear in your app's "Open in" list are other apps you have control over, then you can add CFBundleDocumentTypes
keys to those apps' info.plists. This tells iOS that the apps can open certain types of files. You specify supported filetypes using UTIs like public.jpeg
and so on, and when a user tries to open one of those file types from a UIActivityViewController, ios will include the supporting applications in the options.
Here's a good discussion of that: How do I get my application to show up in the Open in... menu
And here's a discussion on UTIs: Uniform Type Identifier Concepts
So, for example, if one of your apps supported opening jpeg images and any text file, you would add this to the info.plist:
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Images</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.jpeg</string>
</array>
</dict>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>text</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.plain-text</string>
</array>
</dict>
</array>
But, again, if you're trying to manipulate the apps that are shown as "Open in" options from the app displaying the activity controller, you can't. You can only make your own apps advertise that they support certain document types, and from that iOS builds up its "Open in" options.