Skip to content

Commit a42d1d8

Browse files
dmastagihadeed
authored andcommitted
fix(): add platform is cordova check for ionic serve / browser usage (#78)
* add platform is cordova check for ionic serve / browser usage * fix init to isInit
1 parent d797f57 commit a42d1d8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/providers/image-loader.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,25 @@ export class ImageLoader {
7878
private fileTransfer: FileTransfer,
7979
private platform: Platform
8080
) {
81-
Observable.fromEvent(document, 'deviceready').first().subscribe(res => {
82-
if (this.nativeAvailable) {
83-
this.initCache();
84-
} else {
81+
platform.ready().then(() => {
82+
if (!platform.is('cordova')) {
8583
// we are running on a browser, or using livereload
8684
// plugin will not function in this case
8785
this.isInit = true;
8886
this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.');
87+
} else {
88+
Observable.fromEvent(document, 'deviceready').first().subscribe(res => {
89+
if (this.nativeAvailable) {
90+
this.initCache();
91+
} else {
92+
// we are running on a browser, or using livereload
93+
// plugin will not function in this case
94+
this.isInit = true;
95+
this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.');
96+
}
97+
})
8998
}
90-
})
99+
});
91100
}
92101

93102
/**

0 commit comments

Comments
 (0)