Code Monkey home page Code Monkey logo

Comments (19)

pwlin avatar pwlin commented on July 20, 2024

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.

 avatar commented on July 20, 2024

I am using
"name": "cordova-plugin-file-opener2",
"version": "2.0.0",

from cordova-plugin-file-opener2.

abhinavgujjar avatar abhinavgujjar commented on July 20, 2024

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.

abhinavgujjar avatar abhinavgujjar commented on July 20, 2024

@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.

TankOs avatar TankOs commented on July 20, 2024

Same issue here.

from cordova-plugin-file-opener2.

pwlin avatar pwlin commented on July 20, 2024

Use fileEntry.toURL(). Will that solve your problem?

from cordova-plugin-file-opener2.

barbax avatar barbax commented on July 20, 2024

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.

pwlin avatar pwlin commented on July 20, 2024

What is the value of filePath?

from cordova-plugin-file-opener2.

barbax avatar barbax commented on July 20, 2024

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.

pwlin avatar pwlin commented on July 20, 2024

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.

barbax avatar barbax commented on July 20, 2024

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.

barbax avatar barbax commented on July 20, 2024

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.

pwlin avatar pwlin commented on July 20, 2024

Ok glad you resolved your issue. good luck.

from cordova-plugin-file-opener2.

Tobiaswk avatar Tobiaswk commented on July 20, 2024

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.

davidzas avatar davidzas commented on July 20, 2024

@Tobiaswk I also tried both and the problem persists. Did you already find the solution?

from cordova-plugin-file-opener2.

Tobiaswk avatar Tobiaswk commented on July 20, 2024

@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.

pwlin avatar pwlin commented on July 20, 2024

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.

Tobiaswk avatar Tobiaswk commented on July 20, 2024

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.

pwlin avatar pwlin commented on July 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.