cordova-plugin-liveupdate
A fork of cordova-plugin-ionic(original repo: https://github.com/ionic-team/cordova-plugin-ionic).
(※ cordova-plugin-ionic has been built for a legacy function of ionic cloud in the past, and it is being used for a new features of Ionic Pro with auto-testing/deployment, etc )
Now we use it in the UpdateManager
of FieldFLEX 11, and it uses minimum features of the plugin: 3 methods (initialize, download, install and restart).
Supported platforms: iOS, Android
Installation
cordova plugin add cordova-plugin-liveupdate
The plugin will be available on window
as IonicCordova
How To Use
Before you proceed
A new updates should be exist in the HOST_URL(ex: https://sever-url/updates.ffx), it should be named to www.zip
, so that you should be available to download www.zip
file when you link HOST_URL.
How to generate www.zip
? Compress www
directory (build files
) from the latest codebase, can use any Zip tools
.
Cordova API
API | DESCRIPTION |
---|
IonicCordova.deploy.init(config, success, failure) | Required - Initializes the plugin with an app ID and API host specified in js-land. Can be used to change these variables at runtime. |
IonicCordova.deploy.check(success, failure) | - Check for updates from a specified channel, will change the saved channel from the install step. |
IonicCordova.deploy.download(success, failure) | - If an update is present, download it. |
IonicCordova.deploy.extract(success, failure) | - If an update has been downloaded, extract it and set the default redirect location for next app start. |
IonicCordova.deploy.redirect(success, failure) | - Redirect to the latest version of the app on this device. |
IonicCordova.deploy.info(success, failure) | Archived - (ignore it for now.) Get info on current version for this device. |
IonicCordova.deploy.getVersions(success, failure) | Archived (ignore it for now.) - List downloaded versions on this device. |
IonicCordova.deploy.deleteVersion(uuid, success, failure) | Archived (ignore it for now.) - Delete a downloaded version by UUID from this device. |
Sample
const deployConf = {
appId: 'fieldflex-eleven',
host: `${FieldFLEX.serverUrl}/updates.ffx`
};
const deploy = window.IonicCordova.deploy;
if (deploy) {
deploy.init(deployConf, callback, error);
}
...
const deploy = window.IonicCordova.deploy;
if (deploy) {
deploy.download(callback, error);
}
...
const deploy = window.IonicCordova.deploy;
if (deploy) {
deploy.extract(callback, error);
}
...
const deploy = window.IonicCordova.deploy;
if (deploy) {
deploy.redirect(callback, error);
}
...