You will need to include the cordova.js script in the html files where you want to use imgcache.js - see the examples
folder.
imgcache.js should be initialised and used after the deviceready event has been fired.
For instance if the code calling imgcache.js is within a function called yourCallbackFunction
:
document.addEventListener("deviceready", yourCallbackFunction, false);
This section lists the configuration needed to make imgcache.js work with Cordova/Phonegap. This configuration takes place in the config.xml file of your Cordova project.
See config.xml at the root of this project as an example.
imgcache.js requires the following Cordova features/plugins:
For each of these plugins you will be required to define the corresponding package for the OS you target. Here is a default configuration for both iOS and Android :
<feature name="Device">
<param name="ios-package" value="CDVDevice" />
<param name="android-package" value="org.apache.cordova.device.Device" />
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile" />
<param name="android-package" value="org.apache.cordova.file.FileUtils" />
</feature>
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer" />
<param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer" />
</feature>
Features need to be added this way:
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/device"/>
<feature name="http://api.phonegap.com/1.0/network"/>
For Phonegap Build you also need to list all core plugins used (= each feature):
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.file-transfer" />
In order to cache remote images via http it is important to allow access to those domains. This can be setup via a whitelisting <access>
element in your config.xml file.
If you only want to do tests you can allow access to all domains to avoid this kind of issues:
<access origin="*" />
In order to avoid possible security issues, always limit the allowed domains list whenever possible.
For more information about this access origin configuration see Whitelist Guide.