pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
314 stars 584 forks source link

ios:App crashes when opening a file #242

Closed wenjianli92 closed 5 years ago

wenjianli92 commented 5 years ago

I am using the latest 2.1.2 version I use ionic, ionic info:

App crashes when opening a file using the open method, at iphone 6 plus and ipad ios:12.1

![Uploading image.png…]()

wenjianli92 commented 5 years ago

image

wenjianli92 commented 5 years ago

image Display the above error in xcode

shnist commented 5 years ago

hi @wenjianli92, thanks for raising this issue. There was some worked that was merged in recently that seems to be causing a lot of problems now. I forgot it was there when I published the patched version. I'm going to remove it from the master branch for now and release a new patch version today.

shnist commented 5 years ago

patch 2.1.4 has been released which fixes this crash. 2.1.2 has been deprecated. Can you try updating to the latest to check the issue has been fixed for you?

wenjianli92 commented 5 years ago

Thank you for your efforts, now I am going to update to 2.1.4 to try

wenjianli92 commented 5 years ago

@shnist Still can't, reported the following error image

shnist commented 5 years ago

hi @wenjianli92, interesting. I could reproduce the crash in 2.0.12, but it was fixed for me in 2.0.14. Can you show me the output of cordova info and a code snippet from your application if able?

wenjianli92 commented 5 years ago

hi @shnist, Sorry, I stopped this job for some reason ,I use ionic ,Ionic information is as follows: image

I am using a third-party plugin to do the function of sending and receiving files in a chat session, and using one of its APIs to perform the download. After the download is successful, it will return a path(“this.fileurl” in the code below).

console.log(this.fileurl,mymimetype,'=====================fileurl,mymimetype,63'); await this.fileOpener.open(this.fileurl,mymimetype);

The xcode output is as follows:

image

The file path starts with '/var/mobile'. Is this wrong? Then how can I get the correct file path?

wenjianli92 commented 5 years ago

This problem is caused by the wrong path:

let localentry: Entry = await this.file.resolveLocalFilesystemUrl('file://'+this.fileurl); let fileEntry = localentry as FileEntry; fileEntry.file((myfile)=>{ if(this.nativeService.isIos()){ this.fileOpener.open(localentry.nativeURL,myfile.type); } },(err)=>{ console.error(err); });

shnist commented 5 years ago

hi @wenjianli92, glad to hear you were able to resolve your issue.