3
votes

I am developing an iPad application which is capable of downloading different types of files from web. I want to give user's, option to open downloaded files (those my application cant handle) to other applications installed in the device.

I know this can be done by using UIDocumentInteractionController, but i want to skip the show options in this method.

For example: After downloading a pdf file from web, on tapping a button "Open", it should automatically open to adobe reader application in the device.

CustomURL is a useful method to launch a specific application, but it may be difficult to get URL schemes of some applications.

Please share your thoughts.

Thanks in advance.

2
You need the URL to make it work. Registered URLs in the installed apps are the basis behind the doc interaction controller.Wain
Is there any method to get URLs or related details from UIDocumentInteractionController?itZme
Unlikely. You could maybe get the app names from the UI but not the underlying URLs.Wain

2 Answers

0
votes

You need to do a method and call either from web option or local (do you want this?)option.

From web directly:

UIWebView *theWebView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];

NSURL *targetURL = [NSURL URLWithString:@"http://yoursiteweb/directory/file.pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[theWebView loadRequest:request];

[self.view addSubview:theWebView];

From your bundle after you I downladed the file:

UIWebView *theWebView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];

NSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[theWebView loadRequest:request];

[self.view addSubview:theWebView];
0
votes

For example: After downloading a pdf file from web, on tapping a button "Open", it should automatically open to adobe reader application in the device.

You want to open another app. If you don't know its URL schema, how could you open it? Through URL schema is the only way we can use to launch another app in one app. Apple does not provide a way to get the list of app that can open the file. So you need to know the exact URL schema for every app you want to open. Indeed a little frustrating.