Comments (19)
Which version of plugin are you using? I recently upgraded the plugin to 2.0.0
Are you using the latest version?
from cordova-plugin-file-opener2.
I am using
"name": "cordova-plugin-file-opener2",
"version": "2.0.0",
from cordova-plugin-file-opener2.
I have the exact same issue. Could this be because all the cordova.file.* locations provided are private. Which means that while the image can be saved and shared, it cannot be directly opened. Sounds a bit weird, but hey - that's iOS most of the times.
Also - I just checked and if you stored it in application specific folder in android, it doesn't work there either. I think that this is a permissions issue.
from cordova-plugin-file-opener2.
@ashishsingh16 - I have the exact same scenario and I've looked at a couple of options - one is using the inAppBrowser plugin (this plugin is able to access the image it gets scaled weirdly at least for me).
The other option is simply to use HTML to display the image with a pinch to zoom option on the same page itself.
from cordova-plugin-file-opener2.
Same issue here.
from cordova-plugin-file-opener2.
Use fileEntry.toURL()
. Will that solve your problem?
from cordova-plugin-file-opener2.
Same issue here. This is the snippet of code that used to work before iOS update:
cordova.plugins.fileOpener2.open(
filePath,
'application/pdf',
{
error: function (e) {
console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
},
success: function () {
console.log('file opened successfully');
}
}
);
any idea?
from cordova-plugin-file-opener2.
What is the value of filePath
?
from cordova-plugin-file-opener2.
filePath value is like this:
file:///var/mobile/Containers/Data/Application/96AB1E9D-A011-46DD-B774-9AA572FBB80C/Library/NoCloud/(05)@motion_Luglio_2009.pdf
It's generated this way:
var filePath = getFS() + theFileName;
from cordova-plugin-file-opener2.
Go to FileOpener2.m
file and at line 50, change:
fileURL = [NSURL URLWithString:path];
to:
fileURL = [NSURL fileURLWithPath:path];
Does that help?
from cordova-plugin-file-opener2.
On my code the situation was the opposite than you described (since my plugin version is outdated).
In line 50 there was
fileURL = [NSURL fileURLWithPath:path];
that i changed to
fileURL = [NSURL URLWithString:path];
Now its working again.
I just noticed that i'm using version 1.0.11 (did't update for a while).
Now, i'll try tu upgrade and check what does happen.
from cordova-plugin-file-opener2.
i Update the plugin to the latest version (that is using fileURL = [NSURL URLWithString:path];), and everything works fine. Sorry for the confusion and thanks for your support.
from cordova-plugin-file-opener2.
Ok glad you resolved your issue. good luck.
from cordova-plugin-file-opener2.
I'm experiencing the same problem. It does not matter whether I use [NSURL URLWithString:path] or [NSURL fileURLWithPath:path].
from cordova-plugin-file-opener2.
@Tobiaswk I also tried both and the problem persists. Did you already find the solution?
from cordova-plugin-file-opener2.
@davidzas I did solve it. I did my own implementation; https://github.com/Tobiaswk/cordova-plugin-file-opener2
I differentiate between regular files and pdf. If the file passed is a pdf it will open it directly. I'm not sure it is what you want, but the most important thing is that it works for me now.
from cordova-plugin-file-opener2.
If all you need is the ability to open a PDF document, you don't even need this plugin altogether :)
You can simply use window.open("url_to_pdf_file.pdf")
to open up the PDF file. Current webkit releases have built-in capabilities for previewing a PDF document without needing any third party tool.
from cordova-plugin-file-opener2.
Sounds great but I can't get that to work.
Resource interpreted as Document but transferred with MIME type application/pdf
from cordova-plugin-file-opener2.
@Tobiaswk
First try to use it like this:
window.open('url_to_pdf_file.pdf', '_system');
(notice the _system
target);
If that still doesn't work, use the official InAppBrowser
plugin which is a drop-in replacement for window.open
Add it to your project and then use it like:
//re-assign window.open at load:
document.addEventListener("deviceready", function() {
window.open = cordova.InAppBrowser.open;
}, false);
// then call window.open normally in other parts of your app:
window.open('url_to_pdf_file.pdf', '_system');
Previously it was a built-in plugin but it seems they split it now into its own repository. By the way, here is the list of all official plugins
Edit: Use _system
instead of _blank
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.