normalizeURL file:///var.. -> http://localhost:8080/var

Hello, I used WKWebView (

import { normalizeURL } from 'ionic-angular';

let path = cordova.file.dataDirectory;
console.log('Original: ' + path);

path = normalizeURL(path);
console.log('Fixed: ' + path);

and have result, not like described in manual:


converted to


but as i understand, should be


1 Like

Sorry for probably silly question, any way to ensure if WKWebView used to render views ?

I had couple vierd bugs related to update to WKWebView, and strange, file:/// still works good.

I am seeing the same thing on iOS. Normalized URL starts with http://localhost:8080 which is then causing me problems later in my code.

And again to this issue.
Example from documentation:

let aaa = "file:///usr/home/dev/app/index.html";
aaa = normalizeURL(aaa);

results “file:///usr/home/dev/app/index.html”

somewhy file:// prefix not removes

and IOS works with file://

I am also working with WKWebview, and experiencing the same issue (even if I am removing file:// manually).
Did you find a solution?

There might be something possible with DomSanitizer or cordova-plugin-file.

FYI, you can test if you are running WkWebView with the following code:

// iOS - WKWebView
if ('ios')) {
  if (window.indexedDB) {
    console.log('[SystemService]', 'iOS', 'WKWebView');
  } else {
    console.log('[SystemService]', 'iOS', 'UIWebView');

I also tried to add/configure Content-Security-Policy (<meta> in the index.html) & add/configure cordova-plugin-whitelist (<allow-xxx ...> in the config.xml) without any success.

Any solution found for this issue?

You could write your own function in a utils folder:

let toNormalize = "file:///var/mobile/Containers/Data/Application/18438A3A-9ABD-440F-9989-0C009A6CCC8C/Library/NoCloud/"

return toNormalize.split("//", 1)[1]

When you changed the path were you able to get the picture or file? I used the normailzeURL like you did and got the same results. I ended up just sub-stringing it to get what I wanted, but I still get an error when accessing files or pictures… domain=pluginkit code=13 query cancelled userinfo= nslocalizeddescription=query cancelled

I’ve the same problem from the last update of plugin webview
<plugin name="cordova-plugin-ionic-webview" spec="^3.1.1">

normalizeUrl() was replaced by convertFileSrc(). It works well on android real device but fails on iOS for me.
So i’m still stucked (i’m using file plugin to read a local video without issue but when i’m trying to display this video “sanitized” link in a videogular or html5 element, it fails on iOS.

let win: any = window; // hack compilator
let safeURL = win.Ionic.WebView.convertFileSrc('file:///myFile/....');

@lucbonnin I have the same problem using these convertFileSrc URLs and even after adding
ionic: to the index.html content-security-policy meta tag, videos with a src like below will still not play:


As a work around, i’ve added
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />

to the config.xml (only for platform iOS). It is a bit ugly i know but i had no other choice except downgrading to webview 1.x and that was ugliest.

I hope @ionic_team will be able to fix this iOS issue soon.

1 Like

@lucbonnin did you find any solution ?
When I use
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />
in config.xml, my app does not work. Process is stopped after splashcreen display.

Here are the Xcode console logs :

2019-06-26 14:25:20.867271+0200 Desticity[1938:262989] Apache Cordova native platform version 4.5.3 is starting.
2019-06-26 14:25:20.868000+0200 Desticity[1938:262989] Multi-tasking -> Device: YES, App: YES
2019-06-26 14:25:20.909471+0200 Desticity[1938:262989] Using UIWebView
2019-06-26 14:25:20.911248+0200 Desticity[1938:262989] [CDVTimer][console] 0.059009ms
2019-06-26 14:25:20.911378+0200 Desticity[1938:262989] [CDVTimer][handleopenurl] 0.079989ms
2019-06-26 14:25:20.913428+0200 Desticity[1938:262989] [CDVTimer][intentandnavigationfilter] 2.020001ms
2019-06-26 14:25:20.913543+0200 Desticity[1938:262989] [CDVTimer][gesturehandler] 0.069022ms
2019-06-26 14:25:20.927413+0200 Desticity[1938:262989] [CDVTimer][backgroundmode] 13.831019ms
2019-06-26 14:25:20.927478+0200 Desticity[1938:262989] [CDVTimer][backgroundmode] 0.007987ms
2019-06-26 14:25:20.950194+0200 Desticity[1938:262989] [CDVTimer][file] 22.660017ms
2019-06-26 14:25:20.956775+0200 Desticity[1938:262989] [CDVTimer][splashscreen] 6.513000ms
2019-06-26 14:25:20.964947+0200 Desticity[1938:262989] [CDVTimer][statusbar] 8.095980ms
2019-06-26 14:25:20.966174+0200 Desticity[1938:262989] [CDVTimer][keyboard] 1.109958ms
2019-06-26 14:25:20.966248+0200 Desticity[1938:262989] [CDVTimer][TotalPluginStartup] 55.090070ms
2019-06-26 14:25:29.903933+0200 Desticity[1938:262989] Resetting plugins due to page load.
2019-06-26 14:25:36.168689+0200 Desticity[1938:262989] Finished load of: file:///var/containers/Bundle/Application/CC50C082-D23D-4AFE-872D-E101F2B2CA7F/

I have been trying to get stored data from this.file.dataDirectory for weeks and this is the only solution that actually worked.

1 Like

thank you so much for this answer, i have been doing thousands of shits to solve this problems, sanititzation, splitting, directory of file and nothing worked. This worked for me!!!