views:

65

answers:

1

Hi,

I want to transfer a PDF received in my inbox to my application. Once I received an email with a PDF attachment and on clicking the attachment it is asking for "view it" and shows the application which supports opening PDF, after clicking the app pdf is opened in that app.In my case I have created an app which will open a pdf file. Now if I click on the pdf received in inbox it is not displaying my application for viewing.

For example if I click the pdf attachment it gives this list of app(stanza) in which pdf can be opened.I want it to list my app also, and clicking on my app I should be able to open the pdf from my app.

Any ideas on how this could be achieved?

+1  A: 

If I'm not wrong, this should be the very same as on Mac OS. You need to add an CFBundleDocumentTypes item to your info.plist. See here for details. This is an example:

<key>CFBundleDocumentTypes</key>
<array>
  <dict>
    <key>CFBundleTypeIconFiles</key>
    <array>
      <string>ICON_FILE_NAME</string>
    </array>
    <key>CFBundleTypeName</key>
    <string>DESCRIPTIVE NAME like PDF document</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSItemContentTypes</key>
    <array>
      <string>DOCUMENT_TYPE_UTI</string>
    </array>
  </dict>
</array>

A list of all available UTIs can be found here. In your case you should use com.adobe.pdf. I think all that is then left is to implement the application delegate - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url and handle the open there...

Max Seelemann
in info.plist ,when i add new information property list ,there is no option as "CFBundleDocumentTypes", should i select urltypes there and select "document icon file name" in that or something similar to it.
Warrior
Just edit it by hand. You can show the file as plaintext via the context menu in Xcode. Dunno what the right name is otherwise.
Max Seelemann
what are the changes to be made, i have changed "DOCUMENT_TYPE_UTI" as "com.adobe.pdf" else kept it same.Should i change any thing else?
Warrior
you should replace all things in CAPITAL_LETTERS...
Max Seelemann
@Max Seelemann-->PDF gets saved under a folder inbox in documents, is there a way i can directly save it under documnets?
Warrior
Don't think so. But you probably can simply move it using `NSFileManager`
Max Seelemann