I saved the file (pdf) in the "documents" directory, and I would like to know how it is possible to detect whether applications (applications) are installed on the mobile device that can open this file (for example, "pdf" files can be opened using "iBooks "," DropBox ", ...). I would like to detect this before calling the "presentOpenInMenuFromRect" method; which shows a list of possible applications that can process a specific file. Desired behavior:
1). Given the pdf file stored in the Document directory, check if the iPhone / iPad application has an “application” that can open this file (iBooks, DropBox, ...). This is what I do not know how to do it.
2) If the iPhone / iPad application cannot open the application, then do nothing, otherwise draw the "Save" button, and then, if the user clicks the "Save" button, then the "presentOpenInMenuFromRect" method will show a list of possible applications that can open this file. I know a way to present a list of applications that can open a file; here is the source code:
Source code associated with the Save button:
- (void) saveFile:(UIWebView*)webView { NSString* fileName = [[NSFileManager defaultManager] displayNameAtPath:webView.request.URL.absoluteString]; #if DEBUG NSLog(@"<%p %@: %s line:%d> File name:%@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __PRETTY_FUNCTION__, __LINE__, fileName); #endif NSURL* fileurl = [NSURL URLWithString:webView.request.URL.absoluteString]; NSData* data = [NSData dataWithContentsOfURL:fileurl]; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* docsDirectory = [paths objectAtIndex:0]; NSString* filePath = [docsDirectory stringByAppendingPathComponent:fileName]; [data writeToFile:filePath atomically:YES]; NSURL* url = [NSURL fileURLWithPath:filePath];
Thanks in advance.
Note. The response time of the call to the presentOpenInMenuFromRect method is about a few seconds, so I want to know if there is another way to detect and get a list of possible applications installed on a mobile device that can open a specific file (pdf, ...)
Genar source share