Skip to content

Commit da035a8

Browse files
madoBakerihadeed
authored andcommitted
feat(image-loader): add ionic webView 2 support (#189)
Closes #187
1 parent cb8fd22 commit da035a8

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/providers/image-loader.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ interface QueueItem {
1818
reject: Function;
1919
}
2020

21+
declare const Ionic: any;
22+
2123
@Injectable()
2224
export class ImageLoader {
2325
/**
@@ -517,7 +519,13 @@ export class ImageLoader {
517519
// therefore the file needs to be copied into that directory first!
518520
if (this.isIonicWKWebView) {
519521
// Use Ionic normalizeUrl to generate the right URL for Ionic WKWebView
520-
resolve(normalizeURL(fileEntry.nativeURL));
522+
if(typeof Ionic.normalizeURL === 'function' ) {
523+
resolve(Ionic.normalizeURL(fileEntry.nativeURL));
524+
} else if (Ionic.WebView && typeof Ionic.WebView.convertFileSrc === 'function') {
525+
resolve(Ionic.WebView.convertFileSrc(fileEntry.nativeURL));
526+
} else {
527+
resolve(normalizeURL(fileEntry.nativeURL));
528+
}
521529
} else if (this.isWKWebView) {
522530
// check if file already exists in temp directory
523531
this.file

0 commit comments

Comments
 (0)