mostafa-mansour1 / previewAnyFile

Cordova Plugin to preview any file in native mode by providing the local or external URL
MIT License
33 stars 31 forks source link

Ionic 3 project - TypeError: Object(...) is not a function #18

Closed danishashfaq closed 3 years ago

danishashfaq commented 3 years ago

I am getting this error TypeError: Object(...) is not a function at this.previewAnyFile.preview() method. Is it something related to not support of this plugin on Ionic 3. I have installed this version in an Ionic 3 project. Is there any way to use this plugin with "ionic-angular": "3.9.2"?

mostafa-mansour1 commented 3 years ago

First of all, try to use the latest version, and use previewPath instead of preview,

kindly let me know if the issue still exists,

  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"
    );