cordova-plugin-ionic-webview: convertFileSrc producing output starting with 'undefined'

Environment info: cordova-plugin-ionic-webview 3.1.2 ionic-angular 3.9.2 cordova-android 7.1.4

Running into a problem on Android where the following will intermittently produce either file URIs starting with “http://localhost” or “undefined”

let profileImage = this.win.Ionic.WebView.convertFileSrc( this.file.dataDirectory + profileImageFileName );
console.log("processing profileImage = " + profileImage);

Example output when it works: processing profileImage = http://localhost/_app_file_/data/user/0/com.company.app/files/724MjcgqPDur83ZAMyErlw==-image.jpg" Example output when it fails: processing profileImage = undefined/_app_file_/data/user/0/com.company.app/files/724MjcgqPDur83ZAMyErlw==-image.jpg"

This issue seems to happen intermittently on Android platform only. Possibly related to https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/193 The workaround in #193 does not solve my issue.

Any suggestions?

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 3
  • Comments: 20 (7 by maintainers)

Most upvoted comments

Thanks for your reply! I just realized this error only occured when I’m using the --devapp option. This was bugging me as hell so I deployed it to my actual device and it worked 👍

It would be great if you could try this on the devapp and let me know if it works for you. When using an emulator (Android Studio) everything works fine…

I fail to believe that this was ever tested:

import { WebView } from '@ionic-native/ionic-webview/ngx';


constructor(private webview: WebView) { }

...

img = this.webview.convertFileSrc('file:///Users/dan/camera-image-12345.png')

I can’t reproduce, can you provide some sample project or steps to reproduce?

What does it return for you? I want to see an example of the url that this function has to return on android platform given this: this.webView.convertFileSrc(‘file:///Users/dan/camera-image-12345.png’). I also get undefined/app_file/Users/…