@@ -66,6 +66,10 @@ export class ImageLoader {
66
66
return this . platform . is ( 'ios' ) && ( < any > window ) . webkit ;
67
67
}
68
68
69
+ private get isIonicWKWebView ( ) : boolean {
70
+ return this . isWKWebView && location . host === 'localhost:8080' ;
71
+ }
72
+
69
73
constructor (
70
74
private config : ImageLoaderConfig ,
71
75
private file : File ,
@@ -115,7 +119,7 @@ export class ImageLoader {
115
119
116
120
this . file . removeRecursively ( this . file . cacheDirectory , this . config . cacheDirectoryName )
117
121
. then ( ( ) => {
118
- if ( this . isWKWebView ) {
122
+ if ( this . isWKWebView && ! this . isIonicWKWebView ) {
119
123
120
124
// also clear the temp files
121
125
this . file . removeRecursively ( this . file . tempDirectory , this . config . cacheDirectoryName )
@@ -390,7 +394,7 @@ export class ImageLoader {
390
394
return this . file
391
395
. removeFile ( this . file . cacheDirectory + this . config . cacheDirectoryName , file )
392
396
. then ( ( ) => {
393
- if ( this . isWKWebView ) {
397
+ if ( this . isWKWebView && ! this . isIonicWKWebView ) {
394
398
return this . file
395
399
. removeFile ( this . file . tempDirectory + this . config . cacheDirectoryName , file )
396
400
. catch ( ( ) => {
@@ -442,7 +446,12 @@ export class ImageLoader {
442
446
// now check if iOS device & using WKWebView Engine.
443
447
// in this case only the tempDirectory is accessible,
444
448
// therefore the file needs to be copied into that directory first!
445
- if ( this . isWKWebView ) {
449
+ if ( this . isIonicWKWebView ) {
450
+
451
+ // Ionic WKWebView can access all files, but we just need to replace file:/// with http://localhost:8080/
452
+ resolve ( fileEntry . nativeURL . replace ( 'file:///' , 'http://localhost:8080/' ) ) ;
453
+
454
+ } else if ( this . isWKWebView ) {
446
455
447
456
// check if file already exists in temp directory
448
457
this . file . resolveLocalFilesystemUrl ( tempDirPath + '/' + fileName )
@@ -469,6 +478,7 @@ export class ImageLoader {
469
478
resolve ( fileEntry . nativeURL ) ;
470
479
471
480
}
481
+
472
482
}
473
483
} )
474
484
. catch ( reject ) ; // file doesn't exist
@@ -527,7 +537,7 @@ export class ImageLoader {
527
537
. catch ( ( ) => this . file . createDir ( this . file . cacheDirectory , this . config . cacheDirectoryName , false ) ) ;
528
538
}
529
539
530
- if ( this . isWKWebView ) {
540
+ if ( this . isWKWebView && ! this . isIonicWKWebView ) {
531
541
if ( replace ) {
532
542
// create or replace the temp directory
533
543
tempDirectoryPromise = this . file . createDir ( this . file . tempDirectory , this . config . cacheDirectoryName , replace ) ;
0 commit comments