[File Viewer Plugin] Error on Opening PDF

[File Viewer Plugin] Error on Opening PDF

  
Forge Component
(4)
Published on 22 Aug by Experts
4 votes
Published on 22 Aug by Experts

Hello,


The plugin was working great, but in the last days i couldn't open a donwloaded file.

The Check to verify if the plugin is available is okay, returning true all the time, but when I use the "OpenDocument" action, it returns success false and doesn't open the file.

The same process was working 3 days ago

Hi Eduardo,

Did you try to install a new version of this component  or go in the other hands installing a version before the latest one? Don´t forget to refresh dependencies and generate a new apk/ipa to test it after that.

Let me know if there is any difference after that.

Best  regards

Fabio Fantato

Fábio Fantato wrote:

Hi Eduardo,

Did you try to install a new version of this component  or go in the other hands installing a version before the latest one? Don´t forget to refresh dependencies and generate a new apk/ipa to test it after that.

Let me know if there is any difference after that.

Best  regards

Fabio Fantato

Hi Fantato,


I installed the latest version of the plugin and tried to install a previous version too, also generating a new apk/ipa everytime the plugin version changed.

The two versions had the same behavior.


Good Day,

I have not changed my code and I am experiencing the exact same issue whereas before it worked perfectly. I have reinstalled the latest version of the plugin and generated a new apk/ipa to no avail. It is currently working on iOS but not on Android.

Regards.
John

Hi, may I ask for the error message, is it logged in the ServiceCenter?


John Smith wrote:

Good Day,

I have not changed my code and I am experiencing the exact same issue whereas before it worked perfectly. I have reinstalled the latest version of the plugin and generated a new apk/ipa to no avail. It is currently working on iOS but not on Android.

Regards.
John


Valerie wrote:

Hi, may I ask for the error message, is it logged in the ServiceCenter?


John Smith wrote:

Good Day,

I have not changed my code and I am experiencing the exact same issue whereas before it worked perfectly. I have reinstalled the latest version of the plugin and generated a new apk/ipa to no avail. It is currently working on iOS but not on Android.

Regards.
John


Hi Valerie,

There is no error message and it is not logged in the Service Center. It can however be output as a drop down message using the output of the FileViewerPlugin Logic.


What I receive is Success = "False", ErrorCode = "", ErrorMessage = "".

Regards,
John

Solution

It's the new security from Android Nougat now reject file:/// uri.

The native code in cordova github must be updated to use the new FileProvider approach.

https://developer.android.com/about/versions/nougat/android-7.0-changes

Sharing Files Between Apps

For apps targeting Android 7.0, the Android framework enforces the StrictMode API policy that prohibits exposing file:// URIs outside your app. If an intent containing a file URI leaves your app, the app fails with a FileUriExposedException exception.

To share files between applications, you should send a content:// URI and grant a temporary access permission on the URI. The easiest way to grant this permission is by using the FileProvider class. For more information on permissions and sharing files, see Sharing Files.


It's fixed in the original cordova plugin: https://github.com/sitewaerts/cordova-plugin-document-viewer


But it's not compatible with Outsystems (I tried), so we all have to wait for this plugin developer to implement it.

Solution

Great news, it's been fixed. 


Check in Forge, go to File Viewer plugin, then check Version tab. 

Get version 1.2.0 (beta), it's working perfectly now.

Just pass file uri from File Plugin's SaveFile action.

You need to generate native APK again.


Thank you File Viewer Team for your time and effort.