On iOS devices, the Mail app offers "Open In..." option for attachments. The apps listed have registered their CFBundleDocumentTypes with the OS. What I am wondering is how my app might allow users to open files generated by my app in other apps. Is Mail the only app that provides this feature?
-
1I'm pretty sure the answer is here: http://stackoverflow.com/questions/2774343/how-do-i-associate-file-types-with-an-iphone-application. – Dan Rosenstark Dec 13 '11 at 16:55
-
2The updated article that provides the relevant information can now be found under [Document Interaction Programming Topics](http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/PreviewingandOpeningItems.html#//apple_ref/doc/uid/TP40010410-SW1 "Document Interaction Programming Topics"). – robotpukeko Mar 09 '11 at 06:45
4 Answers
Take a look at the Document Interaction Programming Topics for iOS: Registering the File Types Your App Supports.
As long as you provide your document types in your Info.plist, other apps that recognize that document type will list your app in their "open in" choices. Of course, that presumes that your app creates documents that other apps can open.

- 2,485
- 1
- 19
- 19
-
Thanks! That looks like exactly what I was searching for. And, yes, my app creates .csv and .zip files. – westsider Oct 20 '10 at 21:01
-
you might want to edit your answer to reference new link (Apple has reorganized iOS Reference Library, apparently). – westsider Mar 09 '11 at 16:29
-
I added the document type in my app. for eg i have added type PDF . But when i running the document interaction it just taking the quick look application. – Vipin Vijay Aug 16 '12 at 10:47
-
Is there any way to make my app show up first? When the sheet comes up, it suggests a bunch of apps like AirDrop, Kindle, Messages, Slack etc first -- which can't even open my custom file type -- and then the option to open with my app is all the way at the bottom of the list. – astro4 Aug 10 '20 at 22:10
This is a great tutorial, that helped me.
I have added support for *.xdxf
files in my app. In short, you have to do two things. First - add entries like this to your app's Plist
file:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>XDXF Document</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>com.alwawee.xdxf</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>XDXF - XML Dictionary eXchange Format</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.text</string>
</array>
<key>UTTypeIdentifier</key>
<string>com.alwawee.xdxf</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>xdxf</string>
<key>public.mime-type</key>
<string>text/xml</string>
</dict>
</dict>
</array>
Here, you should add UTExportedTypeDeclarations
only if your file type is unique. Or by other words is not here.
Second - handle delegate method in AppDelegate
:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if (url != nil && [url isFileURL]) {
// xdxf file type handling
if ([[url pathExtension] isEqualToString:@"xdxf"]) {
NSLog(@"URL:%@", [url absoluteString]);
}
}
return YES;
}

- 15,320
- 6
- 84
- 70
-
After following this, Its still not working for me. I have posted the question [here](https://stackoverflow.com/questions/73801682/file-association-in-ios). – NightFuryLxD Sep 21 '22 at 13:36
In order to be visible in the list of "open in..." for all files, you need to add this to your plist
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Open All Files</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>public.content</string>
<string>public.data</string>
</array>
</dict>
</array>
Once your app shows in "open in...", you need to load that file. Most website shows to implement this function:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String, annotation: AnyObject?) -> Bool
{
println("Open URL "+url.path!)
}
But this function that worked fine in IOS 7 crashes in IOS 8. I had to implement the following function instead to get it to work.
func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool
{
println("Open URL "+url.path!)
}

- 486
- 6
- 10
I add my app in "open in" list successfully as follows,
Add a new document type filter, which Name is anything you want and the type is defined in https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1
Hope you can be success too!!
However, the feature I want to implement is "Share" like Facebook or Slack do, I can not make it still...anyone can give me a big hand :(