pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
313 stars 585 forks source link

Is it possible to deal with files that aren't associated with a program? #162

Open LyleCharlesScott opened 6 years ago

LyleCharlesScott commented 6 years ago

Fileopener2 fails to open files with an extension that it doesn't recognize, but that behavior doesn't match ios11 native functionality. I would like fileopener2 to handle the unrecognized file the same way that files, dropbox, etc deal with them. I have an implementation that works great otherwise, but I can't figure out a good way to deal with un-associated file types.

For file extensions without an associated program, ios11 shows the name of the file in a generic way instead of displaying the contents. The export menu is visible the same as with any other file, so you can save, copy, share, attach, do whatever non-opening, generic function you like with the file even though you can't open it.

Otherwise, compliments on writing a very useful tool. I'm using fileopener2 to open files in ios11 beta and for the most part, it's really working great. Thanks very much!

buddh4 commented 6 years ago

I've solved this by using https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin

Something like this:

public openFile(entry, params): Promise<any> {
        return new Promise((resolve, reject) => {
            this.fileOpener.open(entry.toURL(),params.mime).then(resolve).catch(() => {
                this.socialShare.share('Some message', 'Subject', entry.toURL()).then(resolve, reject);
            });
        });
    }

(only tested on Android yet)