#cordova-plugin-hotpushes
Download and cache remotely hosted content.
This plugin is a work in progress and it is not production ready. PR welcome.
cordova plugin add cordova-plugin-hotpushes
- Android
- iOS
- WP8
Parameter | Description |
---|---|
options.src |
String URL to hot push endpoint |
options.versionFileName |
String Name of the json file containing the version information |
options.type |
String (Optional) Defines the hot push strategy applied to the content.The type HotPush.HOTPUSH_TYPE.REPLACE is the default behaviour that completely removes existing content then copies new content from a zip file.The type HotPush.HOTPUSH_TYPE.MERGE will download and replace only content which has changed. |
options.headers |
Object (Optional) Set of headers to use when requesting the remote content from options.src . |
options.archiveURL |
String (Mandatory if options.type === Hotpush.HOTPUSH_TYPE.REPLACE ) URL of the zip containing the files to hot push. |
options.documentsPath |
Object (Optional) Path to the Documents folder (useful for WKWebView) |
options.checkType |
String (Optional) Set to Hotpush.HOTPUSH_CHECK_TYPE.VERSION if you want to use the version number in your version.json instead of timestamp |
options.debug |
Boolean (Optional) Print debug information in the console |
- Instance of
HotPush
.
var hotpushes = new HotPush({
src: 'http://myserver/hot/',
versionFileName: 'version.json',
type: HotPush.HOTPUSH_TYPE.REPLACE,
archiveURL: 'http://myserver/hot/assets.zip'
});
Load the local files at position -1
(see version.json). Return a promise.
Parameter | Description |
---|---|
no parameters |
hotpushes.loadWaitingLocalFiles()
.then((result) => console.log('waiting'))
.catch((err) => console.log(err));
Load the local files at position >= 0. Return a promise.
Parameter | Description |
---|---|
no parameters |
hotpushes.loadLocalFiles()
.then((result) => console.log('all good'))
.catch((err) => console.log(err));
Check if there is a new version available on the server. Return a promise which resolve with either HotPush.UPDATE.FOUND
or HotPush.UPDATE.NOT_FOUND
.
Parameter | Description |
---|---|
no parameters |
hotpushes.check()
.then((result) => {
if (result === HotPush.UPDATE.FOUND) {
// do something. Maybe hotpushes.update() or show a popup ?
}
})
.catch((err) => console.log(err));
Download the files on the server. Return a promise.
Parameter | Description |
---|---|
no parameters |
hotpushes.update()
.then(() => {
location.reload();
})
.catch((err) => console.log(err));
The event progress
will be triggered on each update as the native platform downloads and caches the content.
Callback Parameter | Description |
---|---|
data.progress |
Integer Progress percentage between 0 - 100 . The progress includes all actions required to cache the remote content locally. This is different on each platform, but often includes requesting, downloading, and extracting the cached content along with any system cleanup tasks. |
data.status |
Integer Enumeration of PROGRESS_STATE to describe the current progress state. |
hotpushes.on('progress', function(data) {
// data.progress
// data.status
});
Cancels the content sync operation.
Timestamp of the last check
Timestamp of the last update
An enumeration that describes the current progress state.
Integer | Description |
---|---|
0 |
STOPPED |
1 |
DOWNLOADING |
2 |
EXTRACTING |
3 |
COMPLETE |
An enumeration that describes the type of hotpush to perform.
String | Description |
---|---|
merge |
MERGE |
replace |
REPLACE |
An enumeration that describes the field to look at in the version.json
file.
String | Description |
---|---|
version |
VERSION |
timestamp |
TIMESTAMP |
String | Description |
---|---|
NOT_FOUND |
NOT_FOUND |
FOUND |
FOUND |