Open thenaim opened 5 years ago
I'm facing the same issue
@chrisben , do you have any thoughts on this issue? it seems to be blocking us from implementing the image cache :/
@bossjon , I've resolved the issue by creating a function and utilizingresolveLocalFileSystemURL
as follows:
actuallyNormalize(cacheUrl) {
return new Promise((resolve, reject) => {
window.resolveLocalFileSystemURL(cacheUrl, (entry: any) => {
cacheUrl = entry.toURL();
const ionicNormalizer = window['Ionic'] &&
((window['Ionic'].WebView && window['Ionic'].WebView.convertFileSrc) || window['Ionic'].normalizeURL);
if (typeof ionicNormalizer === 'function') {
cacheUrl = ionicNormalizer(cacheUrl);
resolve(cacheUrl);
} else {
reject('could not find cache url');
}
});
});
}
Modified the cache
function as below:
/**
* Cache is image by using a url. If the image is already cached this method
* will return the URL
* @param src {string}
*/
public cache(src: string): Observable<string> {
return this.notifier$.pipe(
switchMapTo(
this.isCached(src)
.pipe(
flatMap(([path, success]: [string, boolean]) => {
return success ? this.getCachedFileURL(path) : this.cacheFile(path);
}),
mergeMap((url: string) => {
if (this.platform.is('ios')) {
return of(this.normalizeURlWKWview(url));
} else if (this.platform.is('cordova')) {
return from(this.actuallyNormalize(url));
}
}),
map((url: string) => {
return url;
})
)
)
);
}
Note that I'm using from
and of
operators from rxjs
.
import { from, of } from 'rxjs';
I am facing the same issue so I have changed in code while returning URL from getLocalCacheUrl method and need to replace because now we need URL in this format
2+ weeks of work right here to determine that;
On iOS, the problem is the version of imgcache. The latest is 2.1.1, and using that with webview 2.5.2, the map crashes with custom avatar. Reverting to imgcache version 2.0.0 (which is what we used previously), causes the map avatar to show without the map crashing on iOS. On Android, reverting imgcache alone doesn't fix the problem. Reverting from webview plugin version 2.5.2 to 2.5.1 ixes the issue (map avatar shows and app doesn't crash). However, reverting to 2.4.0 didn't fix the issue. This may explain why some older builds didn't work that formerly did, until we were using webview plugin version 2.4.0.
error link:
cdvfile://localhost/persistent/imgcache/58f0fa6c8f79117ebbc575b1214450e63a7563d1.jpeg
screenshotPs: I took all the steps CORDOVA.md, but still does not work and do not understand what the problem is. Pss: running app on android device
app.component.ts
image-cache.directive.ts
$ ionic info