Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show "Open In..." when a user tries to open email attachments in iOS

I've seen some iOS apps have this function: When a user tries to open an email attachment, they can press and hold on the attachment for a couple of seconds, and a popup menu will appear displaying two buttons. One button reads "Open in iBooks" (for example). When user clicks it, then the app will be run and open the attachment.

I would like to know how to register my application to be associated with a particular document type.

Also what happens to the document when it is opened? Is it copied to a location that can be read by the application, or does the application receive some sort of object representing the document?

If anyone knows how to do this, please let me know. Thx very much.

like image 262
Jing Avatar asked Aug 04 '10 01:08

Jing


People also ask

Why do attachments not open on iPhone?

Make sure the download process is complete You won't be able to open or view an email attachment on your iPhone until it has downloaded completely. If you see that the attachment is still Downloading or when the download circle is not yet complete, then wait until it finished before opening the file.

How do I get email attachments to open in full screen on iPad?

Question: Q: E-mail attachments Answer: A: Answer: A: The easiest way to switch from Slide Over to a full-screen window is to touch-and-hold the small drag-bar at the top of the Slide Over Window, drag to the top-centre of the screen - then release; this window will become full screen.


2 Answers

Your app has to register its ability to open specific file types by setting the CFBundleDocumentTypes in its plist. Here's an example of GoodReader's XML for opening PDFs.

When you app is called to open a file, you can find the information about the file in application:didFinishLaunchingWithOptions:, which is passed a dictionary with the key UIApplicationLaunchOptionsURLKey

You'll get a URL pointing to the file to open. I think that it's read-only and you'll have to save your own version if you want to change it.

like image 107
nevan king Avatar answered Oct 27 '22 19:10

nevan king


http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html%23//apple_ref/doc/uid/TP40010411-SW1

Is what you need :-)

like image 27
Lee Armstrong Avatar answered Oct 27 '22 20:10

Lee Armstrong