How to launch an iPhone application with a document using a document file type?

In this topic, we will learn how to associate MIME types and file suffixes with your iPhone application so that your application gets called when someone tries to open a document of this type. Great.

I am wondering how to call this magic from another application: given a document with a known MIME type, how can I ask iOS to "launch any application that accepts this document"?

Notice, I said “document”, not “URL” ... I tried to call UIApplication.openURL()with an HTTP URL pointing to the corresponding document (which lives on a web server that serves it with the correct MIME type), iPhone (in fact In fact, iPad 3.2 times in this case) launches Safari, which downloads the document, looks at the MIME type, and then shows the icon for the document and the "Open in [Other App]" button. This works, but is ugly and requires an additional and seemingly unnecessary jump through Safari.

If I manually upload the document myself, save it in a temporary file (with the appropriate suffix for the file that should be recognized by the "other application"), and then call the URL UIApplication.openURL()with the file file://, which simply fails.

+3
source share
1 answer

Take a look at the UIDocumentInteractionController.

Example for iPad:

https://developer.apple.com/library/ios/#documentation/General/Conceptual/iPadProgrammingGuide/CoreApplication/CoreApplication.html#//apple_ref/doc/uid/TP40009370-CH6-SW12

(lightly scroll to “View and open files”) - this anchor scrolls the page too much)

+2
source

Source: https://habr.com/ru/post/1775075/


All Articles