Skip to content
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

previewPath function doesn't seem to be compatible with Cordova #41

Open
christian-kolb opened this issue Nov 11, 2021 · 6 comments
Open

Comments

@christian-kolb
Copy link

For some reason only preview works but previewPath does not. When I use previewPath I get the following error:

Unhandled Promise Rejection: Error: The old format of this exec call has been removed (deprecated since 2.1). Change to: cordova.exec(null, null, 'Service', 'action', [ arg1, arg2 ]);

I'm using the latest version (0.2.9) with Capacitor 3 and Ionic @ionic-native/core 5.36.0 (I don't know if that's relevant).

Let me know if you need any more information for reproduction or when I can test something for you 🙂

@sharkdong
Copy link

the same error , I don't know how to sollution this question

@mostafa-mansour1
Copy link
Owner

don't use ionic wrapper, use it directly like

  window.PreviewAnyFile.previewPath(
        win =>
            {
                if (win == "SUCCESS") {
                    console.log('success')
                } else if (win == "CLOSING") {
                    console.log('closing')
                } else if (win == "NO_APP") {
                    console.log('no suitable app to open the file (mainly will appear on android')
                } else {
                    console.log('error')
                }
            },
        error => console.error("open failed", error),
        "file://filepath/filename.ext"
    );

@vochitan90
Copy link

vochitan90 commented Oct 27, 2022

Hi @mostafa-mansour1

Today I try to use previewPath in ionic capacitor to open an external pdf file via a link - the message return success but it can not preview the file :(

My code look like this:

public async previewFile(): Promise<void> {
        await this.loadingService.presentLoader('Loading...');

        this.documentService
            .previewPath('https://file-examples.com/wp-content/uploads/2017/10/file-sample_150kB.pdf', {
                name: 'tan_vo.pdf',
                mimeType: 'application/pdf'
            })
            .subscribe((res) => {
                console.log(res);
                this.loadingService.dismissLoader();
            });
    }

and the result:

image

@mostafa-mansour1
Copy link
Owner

mostafa-mansour1 commented Oct 27, 2022 via email

@vochitan90
Copy link

vochitan90 commented Oct 27, 2022

Hi @mostafa-mansour1

Thank you for your answer.

I manage to preview the pdf file via a new link https://www.africau.edu/images/default/sample.pdf

When I read the document, you mentioned about your pull request didn't merge yet and need to copy after install the link since 02.02 -> So did you merge it?

image

Also please update the link (How to use in ionic project) -> PAGE NOT FOUND

@mostafa-mansour1
Copy link
Owner

mostafa-mansour1 commented Oct 27, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants