We have a code to download a PDF from the server using a SOAP protocol.
We store the file on the Documents folder of the iOs device, and the we want to allow the user to open the file (usually PDF's files)
But, at least on the simulator, the application didn't open the file successfully.
Of course, I can open manually the file (in order to check that the file has been downloaded perfectly)
// Get the documents folder where write the content
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:documentDownloaded.fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:[self getFileCompletePath]]){
NSString *filePath = [[NSString alloc] initWithFormat:@"%@", [self getFileCompletePath]];
NSURL *url = [[NSURL alloc] initFileURLWithPath:filePath];
if ([[UIApplication sharedApplication] canOpenURL:url]){
[[UIApplication sharedApplication] openURL: url];
} else {
NSLog(@"Not supported application to open the file %@", filePath);
}
[url release];
[filePath release];
}
The file full path in the simulator is:
/Users/User/Library/Application Support/iPhone Simulator/4.3.2/Applications/87800296-2917-4F26-B864-B20069336D1D/Documents/0000907.pdf
Anybody knows if is something wrong?
The file could be and spreadsheet, pdf, image, document ... but for the first work around will be great just for pdf's.
Thank you,