Comments (25)
What if you use fileEntry.toURL()
in your javascript?
from cordova-plugin-file-opener2.
Hi,
Where to get the fileEntry.toURL() ?
I don't understand. Do you have an example with fileEntry.toURL() ?
from cordova-plugin-file-opener2.
@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);
}
);
from cordova-plugin-file-opener2.
@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
from cordova-plugin-file-opener2.
- What iOS version and device are you using?
- Which app have you installed on your iOS device for reading rtf files?
- Is
fullPath
a valid path? Does the file really exists there?
from cordova-plugin-file-opener2.
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:
docController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
from cordova-plugin-file-opener2.
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).
from cordova-plugin-file-opener2.
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. :)
from cordova-plugin-file-opener2.
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
Tom
from cordova-plugin-file-opener2.
Uh, I found the problem. In my config.xml
I used following preference:
<preference name="iosPersistentFileLocation" value="Library" />
It seems, that this does not work well with the plugin. After removing this line, it worked.
from cordova-plugin-file-opener2.
@tomraithel Thank you very much, I added this tip as a note to the readme file.
from cordova-plugin-file-opener2.
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:
cordova.plugins.fileOpener2.open(
uri, //cdvfile://localhost/persistent/myPDF.pdf
'application/pdf',
{
error: function (e) {
console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
},
success: function () {
console.log('file opened successfully');
}
});
I've checked the following:
The succes callback is hit
My config.xml doesn't contain iosPersistentFileLocation preference setting
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
A2I
from cordova-plugin-file-opener2.
Try to change plugin's ios source (FileOpener2.m) line:
fileURL = [NSURL URLWithString:path];
to:
fileURL = [NSURL fileURLWithPath:path];
Does that help?
from cordova-plugin-file-opener2.
I found the following lines in the FileOpener2.m file:
//fileURL = [NSURL URLWithString:path];
fileURL = [NSURL fileURLWithPath:path];
I tried enabling the first line (URLWithString) but this resulted in a crash of my app.
from cordova-plugin-file-opener2.
That solved it. Thank you very much.
from cordova-plugin-file-opener2.
Ok great. I will add a note to README file about using fileEntry.toURL()
from cordova-plugin-file-opener2.
@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
from cordova-plugin-file-opener2.
I use the following helper instance to download and open all sort of files.
I removed some code that applied to our internal netwerk but you should be able use this.
I hope this helps anyone out there struggling with this. If i can be of assistance let me know
from cordova-plugin-file-opener2.
@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)
TestSolution.txt
from cordova-plugin-file-opener2.
@Belheni I looked at the code snippet you added and this seems fine to me and should work.
The only thing i could find that is off is your invocation of openFile(entry.toURL()). Shouldn't this be OpenFile(entry.toURL())?
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.
from cordova-plugin-file-opener2.
@pwlin and @any2info i opened the file in ios but how to detect the click done on the file to close it?or how to detect the closing of the file?
another question is that how to display file in ios on the window inappbrowser and not under the window inappbrowser (default)? Please help me
from cordova-plugin-file-opener2.
@Belheni When you want it to open in inappbrowser this should work. Detecting close this maybe
from cordova-plugin-file-opener2.
@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
from cordova-plugin-file-opener2.
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.
from cordova-plugin-file-opener2.
Hola estoy creando mi app online con PhonegapBuild.
Como agrego el plugin en el config.xml?
Hello, I am creating my online app with PhonegapBuild.
How do I add the plugin in the config.xml?
from cordova-plugin-file-opener2.
Related Issues (20)
- FileOpener2 error in electron 11 HOT 1
- Plugin is not handling Cookies in React project HOT 1
- Add documentation for error codes
- USB PORT PARAM HOT 1
- doesnt work with IOS and assets-library
- Usage in Capacitor HOT 1
- pdf opened in an external app cannot save changes HOT 1
- Cannot open file while is at app data location '/data/data/<app_id>/cache' HOT 2
- unable to open application/pdf format in Android device (Samsung Galaxy S21 and Samsung Galaxy S21+) HOT 2
- android.support.v4.content.FileProvider not found HOT 7
- Relative URIs are not supported.
- remove: android.permission.REQUEST_INSTALL_PACKAGES from plugins.xml HOT 85
- Text Open file in always localized in english (Android) HOT 4
- There was a problem parsing the package for android install apk HOT 1
- Can't edit file HOT 2
- Getting error after updating plugin to 4.0.0 on Android Studio HOT 2
- Unable to open some MP4 files on iOS? HOT 1
- This plugin has a maintained forked repo now - please use and follow HOT 4
- Error: Current working directory is not a Cordova-based project.
- iPadOS not supported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-file-opener2.