0

I have the following question:

I need to load a PDF into an App, which the user can select. I don't really care where this PDF comes from though. Is there any way, that the my App switches to an other App, such as Dropbox or iBooks, then the user selects a PDF and then the PDF is loaded into my app, where the user can do stuff with it?

c2programming
  • 235
  • 3
  • 17

3 Answers3

1

It partly depends on how you configure your app and partly on whether the other app does file sharing. Here's an Apple reference for how you do your portion of the job: QA1587

I have it working in an app when the PDF comes from Safari or Mail, as examples. (I don't think iBooks supports it…not sure about Dropbox.)

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
0

You should register your app with file types it can open. The app will then appear in other apps as possible target to open files selected by the user.

Consult with Apple documentation.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
0

Read about registering file types that your app is capable of opening, and the use of a Document Interaction Controller.

In summary...

Register which file types your app supports (in your particular case a PDF type).

The image below indicates settings that will accept many if not all file types that open within a UIDocumentInteractionController.

Project Info - Document Types

Once this setting is in place, when the user of another app that implements a Document Interaction Controller opens a PDF file, and taps the Action button, your app will be included under the "Open In..." options.

So, how to receive that information...

In your appDelegate.m, include a receiver within the UIApplicationDelegate method application:didFinishLaunchingWithOptions:, the options part of this being what you are interested in receiving, and if necessary parsing.

This is the link to a good article by Mattt Thompson on the subject.

Also in your appDelegate.m, include code in the UIApplicationDelegate method application:openURL:sourceApplication:annotation: to control how your app responds to the previously mentioned "Open In..." command from another app. It is here that you write the code to ensure your app opens and responds properly when it is called to be opened from another app.

Hope this helps.

andrewbuilder
  • 3,629
  • 2
  • 24
  • 46