ionic-cache-src icon indicating copy to clipboard operation
ionic-cache-src copied to clipboard

iOS - Cached images not found

Open blattmann opened this issue 9 years ago • 1 comments

Hi,

where exactly does this plugin store the files on iOS?

I use var localUrl = cordova.file.dataDirectory; what resolves to file:///var/mobile/Containers/Data/Application/<UUID>/Library/NoCloud/

If the device is offline I receive this error:

Failed to load resource: file:///var/mobile/Containers/Data/Application/<UUID>/Library/NoCloud/eroq1wz4bJTzfEbT.jpg
The requested URL was not found on this server.

On Android all works fine.

On top I had to change the code block starting at: https://github.com/BenBBear/ionic-cache-src/blob/master/ionic-cache-src.js#L169

to avoid returning undefined:

c.get = function(url) {
    var result = undefined;
    if (needDownload(url)) {
        var cache_url = c._cache[url] && (getCacheDir() + c._cache[url]);
        result = cache_url || url;
    }
    return result;
};

Thanks for your advice(s).

blattmann avatar Jun 08 '16 06:06 blattmann

The function getCacheDir() is not defined within the factory. It needs to be defined there!

droolingOnU88 avatar Feb 25 '17 10:02 droolingOnU88