(Iphone) associate an App to some file extension to open email attachments in Mail app - iphone

I found that some application, like "GoodReader" or "Docs to Go", once installed can be activated using the "Open in" function when opening an email attachment in the Mail App. How to add this function to have my App to be associated to some kind of documents (like pdf) ?
The idea is to have an easy way to get mail attachments to be used directly inside an app.
Edit: I found this document and think it fits my question:
Document Support
An application can now register the file types it supports with the system and receive notifications when a file of the given type needs to be opened. It does this by including the CFBundleDocumentTypes key in its Info.plist file. An application that registers one or more file types may also be expected to open files of those types at some point later. It does this by implementing the
application:didFinishLaunchingWithOptions:method in its application delegate and look for a file
in the UIApplicationLaunchOptionsURLKey key of the provided dictionary.
Complementing the ability to open files of known types is the addition of the
UIDocumentInteractionControllerclass in the UIKit framework. This class provides a user-based
interaction model for managing files that your application does not know how to open. The document
interaction controller provides options for previewing the contents of a file in place or opening it in another
application. Document interaction controllers are particularly useful for email applications or applications
that may download files from the network.

take a look at Custom URL Schemes and UIDocumentInteractionController. If you are looking to add the "open in" menu, the second link is what you need. If you are looking to register as a "PDF reader" this link (scroll to section about registering your app for certain types) should work iPad Programming Guide

Related

iPhone Display icon in Mail attachement forward actionsheet

How to show application icon in mail document forward actionsheet as shown below.
Description :
Any Document in Mail attachement.
Press and hold until you see action sheet like below image.
Please help me to show my application icon in this action sheet.
Your question is not clear.
Probably you are looking for UIDocumentInteractionController.
UIDocumentInteractionController allows your app to integrate with documents of specified format.
Check these tutorials :
Previewing Documents
Sharing Data
Import/Export Documents
You want to register your application for the file types you are able to receive. Documentation here:
http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html
To declare its support for file types, your app must include the CFBundleDocumentTypes key in its Info.plist property list file. (See “Core Foundation Keys”.) The system adds this information to a registry that other apps can access through a document interaction controller.

Parsing an XML from an e-mail attachment

Is there a way to parse an XML which is attached to an e-mail directly from my app? I have implemented a parser which is reading it from the documents path, but would like to allow the user to be able to directly get it from an e-mail attachment too.
Assuming that you don't want to restrict it to jailbroken files, the easiest way is to register a filetype (Apple docs) with the extension of your data format, so XML if it is a generic XML or some other type if you want to make it specific to your application (and remember if you register XML you will get all XMLs, not just yours), then the user can click on the extension and get the 'Open in....' menu with your application shown in the list.
You need to impliment application:didFinishLaunchingWithOptions:, but it is all in the docs.
A better option would be to give it a filetype that is not commonly used by anything else, so that yours is the only one in the list. I get 4 apps on my iPad for opening XML
There is no way to automatically do it.

How do I open a file with unknown associations in iOS?

I think it's rather impossible, but will ask anyway. My application uses file association to open some types of files. What I need is to make file associations within my app. For example I have some files in my app's Documents folder and when user wants to open that it would be a great idea to ask him in which application he would like it to open (like Mail app does).
It can possibly be done with URL schemes, but if I don't know what applications user has, it can't be used. So, is there any way to use the device's file associations within an application?
You should take a look at Document Interaction Programming Topics for iOS. It explains how you can use the UIDocumentInteractionController class to present the user a list of apps which support a given file.

How can I read documents from other iOS apps?

I have an app which is similar to an FTP client. I can download various types of documents in it. (DOC, XLS, PDF, PPT etc)
Now, I want to read those documents in another application. For example: Suppose I download a PDF in my app, it is possible to read from AirSharing or File Magnet?
I don't think it's possible for other applications to access Library folders owned by other apps, and definitely not private application folders.
Document handling might handle what you want only to an extent - not the files that don't have their types registered to any app, and only at a one by one file basis, essentially duplicating the files as well.
If this is your app you are talking about, you can implement the Open In feature which is part of the Document Interaction in iOS, which will allow the user to access the file in any app that is registered to handle the extension/UTI.
In particular, these methods:
UIDocumentInteractionController
– presentOpenInMenuFromRect:inView:animated:
– presentOpenInMenuFromBarButtonItem:animated:

how to open a file in iWork in the iPad

From what I understand, UIApplication -openFile can open files externally, the application depending on the URL scheme. Say I have a pages (or word maybe?) document, and I want to open it in pages from my app. Does anyone know the URL scheme for me to do that? Is there a list anywhere? (Keynote, and Numbers would also be useful).
It doesn't work that way because you cannot transmit the file via a URL and Pages cannot access a file that is stored in your app's sandbox.
If you want to give the user the option to open a file in Pages in your UI, UIDocumentInteractionController is the way to do that. It presents a UI where the user can preview the file and select to open it in any application that supports the file type.
AFAIK it is not possible with the SDK to do this completely programmatically, i.e. without user interaction.