0

enter image description here

I want to Use file (pdf, images, Doc) downloaded from iPhone's Mail How can i use it? And How can i show my app in options shown when user clicks on share from any file? In short I want to add my app with above options (Open in walnut)

Hardik Nadiyapara
  • 2,436
  • 2
  • 17
  • 24

2 Answers2

2

If your app is capable of opening specific types of files, you should register that support with the system. This allows other apps, through the iOS document interaction technology, to offer the user the option to hand off those files to your app.

To declare its support for file types, your app must include the CFBundleDocumentTypes key in its Info.plistproperty list file

The CFBundleDocumentTypes key contains an array of dictionaries, each of which identifies information about a specific document type.

Each dictionary in the CFBundleDocumentTypes array can include the following keys:

  • CFBundleTypeName specifies the name of the document type.

  • CFBundleTypeIconFiles is an array of filenames for the image resources to use as the document’s icon.

  • LSItemContentTypes contains an array of strings with the UTI types that represent the supported file types in this group.

  • LSHandlerRank describes whether this application owns the document type or is merely able to open it.

Document type information for a custom file format

<dict>
   <key>CFBundleTypeName</key>
   <string>My File Format</string>
   <key>CFBundleTypeIconFiles</key>
       <array>
           <string>MySmallIcon.png</string>
           <string>MyLargeIcon.png</string>
       </array>
   <key>LSItemContentTypes</key>
       <array>
           <string>com.example.myformat</string>
       </array>
   <key>LSHandlerRank</key>
   <string>Owner</string>
</dict>

For more details: Developer.Apple: Registering the File Types Your App Supports

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102
1

You can use UIDocumentInteractionController

-(IBAction)onTouchOpenInButton:(id)sender
{

    if(!documentController)
    {
        documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:loaclFileURL]];
    }
    else{
        documentController.URL= [NSURL fileURLWithPath:loaclFileURL];
    }
    [documentController presentOptionsMenuFromBarButtonItem:sender animated:YES];
}

Check this link

From Apple Docs

A document interaction controller, along with a delegate object, provides in-app support for managing user interactions with files in the local system. For example, an email program might use this class to allow the user to preview attachments and open them in other apps. Use this class to present an appropriate user interface for previewing, opening, copying, or printing a specified file

If you want your app to have the functionality of the screenshot you presented then use UIDocumentInteractionController

If you want your app to be listed in the openin actionsheet(Like open in your app name) see ramshad's answer

Community
  • 1
  • 1
ipraba
  • 16,485
  • 4
  • 59
  • 58