Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically retrieve list of installed apps that support a given file type

While it is clear we cannot retrieve a list of installed applications on iOS, are there any tricks to allow us to determine the list of apps registered for a given file type? That is, the list the user will see in the Open In... menu for that particular file type. canOpenURL only returns a boolean, but ideally it would return us a list of supported installed applications.

like image 370
RealCasually Avatar asked Apr 03 '12 00:04

RealCasually


2 Answers

Open in is certainly possible by the UIDocumentInteractionController You just need to instantiate UIDocumentInteractionController instance:

//Following in header file:
UIDocumentInteractionController *docInteractionController;

Implement the delegate:

<UIDocumentInteractionControllerDelegate>

.m:

//Here the url is the document URL that you want to open (or you want to apply open in functionality)
self.docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docInteractionController.delegate = self;

Open In method will be like following:

- (void) openIn: (id) sender {
    [self.docInteractionController presentOptionsMenuFromBarButtonItem:sender animated:YES];
}

and once you are done:

[self.docInteractionController dismissMenuAnimated:YES];

and that's it. This will list down the list of application supported for document and on selection of them will launch the corresponding application with the document URL we instantiated with.

like image 110
UPT Avatar answered Oct 13 '22 00:10

UPT


I doubt either of your two questions ("determine list of apps for a given file type" or "how to implement 'open in...'") is possible in current versions of iOS as users don't see individual files on the home screens that show apps. Nor can an app do a "open a separate app with this specific file" event (which is something easily doable on a Macintosh with Apple Events).

But these do sound like a great feature requests that you can file with Apple at http://bugreporter.apple.com (which you can log into, if you're a registered Apple developers). If enough people ask for these features (and the potential "open in..." functionality is indeed a frequently requested feature), Apple will strongly consider including them in future iOS releases.

like image 22
Michael Dautermann Avatar answered Oct 13 '22 00:10

Michael Dautermann