-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Files not opening on iOS #2
Comments
|
Sorry it took a while to get back to you on this. So I was in fact having a path issue and have that fixed but now whenever I attempt to open a file the app crashes. I am testing on iOS7.1 iPhone 4. Could still be a path issue, I have tried both of these for testing trying to open a PDF with Adobe Reader with the same result: /Documents/test.pdf and the full path from root: /var/mobile/Applications/ . /Documents/noodles.pdf but am getting a sigabrt at this line: |
I seem to be having the same issue. I do get an "Open with..." dialog if my file path starts with "file://", but the file doesn't open after making a selection. My attempts to use paths without schemas/prefixes have all caused my app to crash like scottdc's. I'm still learning how to navigate the iOS filesystem, so I could just be using the wrong path, but I figured I'd chime in with my experience so far... Any clues you find toward a solution would be much appreciated -- I'll be sure to post my own findings here, as well. Update: I tested opening my file with the Mail app, just to see what would happen. All it did was create a new email with the name of my file in the subject line. The subject line was only the name, not the full path. It didn't even add the file as an attachment (which isn't the surprising, but I thought it worth mentioning). |
I finally got this working! Some recent changes in Cordova require some extra steps to find the absolute system path for a file. For a File Entry, instead of using toURL() or fullpath, you have to use fileEntry.toNativeURL() to get the full system path. Then you can just use the full system path to open the file in whatever apps can open the file type. :) |
Hey, I have a similar problem here. I´m using the example code but I don´t get any error or success - just nothing happens. This is my code: cordova.plugins.fileOpener2.open(
currentFileUrl, // e.g. '/var/mobile/Applications/XXXXXXXXX/Library/files/mypdf.pdf'
'application/pdf',
{
error : function(errorObj) {
alert('Error status: ' + errorObj.status + ' - Error message: ' + errorObj.message);
},
success : function () {
alert('file opened successfully');
}
}
); I also tried file urls with prefix (file://) from fileEntry.toNativeUrl() like @zatch explained, but nothing happens here. @zatch can you give me an example with the code that worked for you? Thanks |
Uh, I found the problem. In my
It seems, that this does not work well with the plugin. After removing this line, it worked. |
@tomraithel Thank you very much, I added this tip as a note to the readme file. |
Hey, I have this exact problem. I'm trying to open a pdf file that has been downloaded to my phone. When execute the following i get a dialog to select the app that should be used:
I've checked the following: I'm working with apache cordova tools for VS2015 (CLI 5.1.1) and i'm trying to use ibooks to open the pdf. I recently upgraded to vs2015 after which this problem arose, so i suspect this to be some kind of cordova configuration issue. Can someone help me with this? Thanks |
Try to change plugin's ios source (FileOpener2.m) line: fileURL = [NSURL URLWithString:path]; to: fileURL = [NSURL fileURLWithPath:path]; Does that help? |
I found the following lines in the FileOpener2.m file: I tried enabling the first line (URLWithString) but this resulted in a crash of my app. |
What if you use |
That solved it. Thank you very much. |
Ok great. I will add a note to README file about using |
Hi, Where to get the fileEntry.toURL() ? |
@ronyrun check code below, and if you need more details about File API I recommend following post: https://www.neontribe.co.uk/cordova-file-plugin-examples/)) window.resolveLocalFileSystemURL(
path,
function (entry) {
console.log(entry.toURL());
},
function (err) {
$log.debug(err);
}
); |
@pwlin and @any2info Can you send me a simple and complete version of opening pdf in ios Please? i really tested all the suggestions(changing in fileOpener, fileEntry.toURL(),fileEntry.toNativeURL()..) and the best version is that i have just a successful message of opening pdf without showing it..I really need a solution for that |
I use the following helper instance to download and open all sort of files. I hope this helps anyone out there struggling with this. If i can be of assistance let me know |
@any2info Thanks for your help but i tested your solution carefully after checking if all plugins exist and nothing is showed.. This is my test really i don't know what's the problem..i will be very thankful if you continue helping me..(if you have a simple project working fine on ios please send it) |
@Belheni I looked at the code snippet you added and this seems fine to me and should work. Also the false and headers parameter can be removed because you probably don't need them. Which should be the case if you are downloading directly from a web uri. In my case i needed them because we are no longer downloading files using uri's. If this still doesn't solve anything, i would be happy to look at more of your code if needed. |
@any2info i work with inappbrowser (for the website) and fileopener2.. i open the PDF file using fileopener2 and it works fines.. my question is how to detect the click done on the file to close it? in android file is displayed on the window inappbrowser but in ios file is displayed under the window inappbrowser.. i want to detect close of PDF to show again the window inappbrowser.. i know that my problem is complicated and i wish that you have a solution |
@Belheni I am afraid im can't help you with that. Maybe you should start stackoverflow item for that since this is no longer is related to files not opening on ios |
The issue I had was with the CGRect passed into presentOpenInMenuFromRect. Changing line 89 to: CGRect rect = CGRectMake( cont.view.bounds.size.width / 2, 20, 166, 235 ); Worked, and made the dialog appear slightly offset from the screen center. |
Hola estoy creando mi app online con PhonegapBuild. Hello, I am creating my online app with PhonegapBuild. |
Been trying to get this working for a bit now and am stumped. Files do not open but I also do not get an error or anything, nothing happens at all. I've got the event writing to the console and it appears to be firing correctly but I get neither a success or failure message. I've got this same basic case for multiple file types (pdf, doc, etc.) based on extension and none of them work.
case 'rtf':
cordova.plugins.fileOpener2.open(fullPath, 'application/rtf', {
error : function(errorObj) {
console.log('error - ' + errorObj.status + ' - ' + errorObj.message);
},
success : function () {
console.log('sucess');
}
});
break;
The text was updated successfully, but these errors were encountered: