Skip to main content

Cordova SDK Reference

The Live Updates API offers programmatic access to the Live Updates SDK and the most control over the user experience.

In order to use the Live Updates API inside of your app, you need to install the latest version of the Live Updates SDK and set the UPDATE_METHOD to none:

ionic live-update add --update-method=none --app-id="YOUR_APP_ID" --channel-name="YOUR_CHANNEL_NAME"

Then you can import the Live Updates API in order to it in your code:

// ES2015/Typescript and Angular version 16 and above
import { Deploy } from 'cordova-plugin-ionic';

...

async changeToBetaChannel() {
await Deploy.configure({channel: 'BETA'});
}

...

// Angular version 15 and below
import { Deploy } from 'cordova-plugin-ionic/dist/ngx';

...

constructor(private deploy: Deploy) {
...
}

async changeToBetaChannel() {
await this.deploy.configure({channel: 'BETA'});
}

...

SDK Configurationโ€‹

The Live Updates SDK uses variables to configure the way the SDK behaves. View configuration options.

Classesโ€‹

Interfacesโ€‹


Classesโ€‹

IonicDeployโ€‹

IonicDeploy:

The Ionic Live Updates SDK API

usage:

async performManualUpdate() {
const update = await Deploy.checkForUpdate()
if (update.available){
// We have an update!
}
}

Methodsโ€‹

The SDK contains many functions that can help you utilize Deploy inside of your app.

checkForUpdateโ€‹

โ–ธ checkForUpdate(): Promise<CheckForUpdateResponse>

description: Check for available updates for the currently configured app id and channel.

since: v5.0.0

usage:

async performManualUpdate() {
const update = await Deploy.checkForUpdate()
if (update.available){
// We have an update!
}
}

Returns: Promise<CheckForUpdateResponse> A response describing an update if one is available.


configureโ€‹

โ–ธ configure(config: IDeployConfig): Promise<void>

description: Update the default configuration for the SDK on the current device. The new configuration will be persisted across app close and binary updates.

since: v5.0.0

usage:

async configureDeploy() {
const config = {
'appId': 'YOUR_APP_ID',
'channel': 'CHANNEL_NAME'
}
await Deploy.configure(config);
}

Parameters:

NameTypeDescription
configIDeployConfigThe new configuration for the SDK on this device.

Returns: Promise<void>


deleteVersionByIdโ€‹

โ–ธ deleteVersionById(version: string): Promise<boolean>

description: Remove the files specific to a snapshot from the device.

usage:

async deleteVersion() {
const versions = await Deploy.getAvailableVersions();
Deploy.deleteVersionById(versions[0].versionId);
}

Parameters:

NameTypeDescription
versionstringThe versionId

Returns: Promise<boolean> true if the update was deleted.


downloadUpdateโ€‹

โ–ธ downloadUpdate(progress?: CallbackFunction<number>): Promise<boolean>

description: Download the new files from an available update found by the checkForUpdate method and prepare the update.

since: v5.0.0

usage:

async performManualUpdate() {
const update = await Deploy.checkForUpdate()
if (update.available){
await Deploy.downloadUpdate((progress) => {
console.log(progress);
})
}
}

Parameters:

NameTypeDescription
Optional progressCallbackFunction<number>A progress callback function which will be called with a number representing the percent of completion of the download and prepare.

Returns: Promise<boolean> true if the download succeeded


extractUpdateโ€‹

โ–ธ extractUpdate(progress?: CallbackFunction<number>): Promise<boolean>

description: Extract a downloaded bundle of updated files.

since: v5.0.0

usage:

async performManualUpdate() {
const update = await Deploy.checkForUpdate()
if (update.available){
await Deploy.downloadUpdate((progress) => {
console.log(progress);
})
await Deploy.extractUpdate((progress) => {
console.log(progress);
})
}
}

Parameters:

NameTypeDescription
Optional progressCallbackFunction<number>A progress callback function which will be called with a number representing the percent of completion of the extract.

Returns: Promise<boolean> true if the extract succeeded


getAvailableVersionsโ€‹

โ–ธ getAvailableVersions(): Promise<ISnapshotInfo[]>

description: Get a list of the snapshots available on the device.

since: v5.0.0

usage:

async checkVersions() {
const versions = await Deploy.getAvailableVersions();
console.log(versions);
// [
// {
// 'versionId': 'versionId1',
// 'channel': 'CHANNEL_NAME',
// 'binaryVersion': '1.0.1'
// },
// {
// 'versionId': 'versionId2',
// 'channel': 'CHANNEL_NAME',
// 'binaryVersion': '1.0.1'
// },
// ]

Returns: Promise<ISnapshotInfo[]> a list of available updates.


getConfigurationโ€‹

โ–ธ getConfiguration(): Promise<ICurrentConfig>

description: Get the current configuration for the SDK on the current device.

since: v5.0.0

usage:

const info = Deploy.getConfiguration();
console.log(info);
// {
// 'appId': 'abcd1234',
// 'channel': 'MY\_CHANNEL\_NAME',
// 'binaryVersionName': 'X.X.X',
// 'binaryVersionCode': 'X.X.X', (string on iOS number on Android)
// 'disabled': false,
// 'updateMethod': 'auto',
// 'maxVersions': 3,
// 'minBackgroundDuration': 30,
// 'currentVersionId': 'xxxx-xxxx-xxxx-xxxx'
// 'currentBuildId' : 'xxxxxxx'
// }

Returns: Promise<ICurrentConfig> The current configuration of the SDK.


getCurrentVersionโ€‹

โ–ธ getCurrentVersion(): Promise<ISnapshotInfo | undefined>

description: Get info about the currently deployed update or undefined if none are applied.

since: v5.0.0

usage:

const info = await Deploy.getCurrentVersion()
console.log(info)
// {
// 'versionId': 'UUID_OF_ACTIVE_CODE',
// 'channel': 'CHANNEL_NAME',
// 'binaryVersion': 'X.X.X'
// }

Returns: Promise<ISnapshotInfo | undefined> The info about the currently applied update or undefined if none is applied.


getVersionByIdโ€‹

โ–ธ getVersionById(versionId: string): Promise<ISnapshotInfo>

description: Get info about the update by its versionId

since: v5.0.0

Parameters:

NameType
versionIdstring

Returns: Promise<ISnapshotInfo> The info about the currently applied update or undefined if none is applied.


reloadAppโ€‹

โ–ธ reloadApp(): Promise<boolean>

description: Reload the app if a more recent version of the app is available.

since: v5.0.0

usage:

async performManualUpdate() {
const update = await Deploy.checkForUpdate()
if (update.available){
await Deploy.downloadUpdate((progress) => {
console.log(progress);
})
await Deploy.extractUpdate((progress) => {
console.log(progress);
})
await Deploy.reloadApp();
}
}

Returns: Promise<boolean> true if the reload succeeded


syncโ€‹

โ–ธ sync(syncOptions?: ISyncOptions, progress?: CallbackFunction<number>): Promise<ISnapshotInfo | undefined>

description: Check for an update, download it, and apply it in one step.

since: v5.0.0

usage:

async performAutomaticUpdate() {
try {
const currentVersion = await Deploy.getCurrentVersion();
const resp = await Deploy.sync({updateMethod: 'auto'}, percentDone => {
console.log(`Update is ${percentDone}% done!`);
});
if (!currentVersion || currentVersion.versionId !== resp.versionId){
// We found an update, and are in process of redirecting you since you put auto!
}else{
// No update available
}
} catch (err) {
// We encountered an error.
}
}

Parameters:

NameTypeDefault valueDescription
Default value syncOptionsISyncOptions(Optional) Application update overrides.

Returns: Promise<ISnapshotInfo | undefined> The info about the currently applied update or undefined if none is applied.



Interfacesโ€‹

CallbackFunctionโ€‹

โ–ธ __call(result?: [T]()): void

A callback function to handle the result.

Parameters:

NameType
Optional result[T]()

Returns: void


CheckForUpdateResponseโ€‹

CheckForUpdateResponse:

The response object describing if an update is available.

availableโ€‹

โ— available: boolean

Whether an update is available.


<Optional> buildโ€‹

โ— build: undefined | string

The id of the build if available.


compatibleโ€‹

โ— compatible: boolean

Equivalent to available since v5 this can be ignored in favor of available

deprecated:


<Optional> incompatibleUpdateAvailableโ€‹

โ— incompatibleUpdateAvailable: undefined | false | true

Whether there is an update available that is not compatible with this device.


partialโ€‹

โ— partial: false

Legacy indicator of whether the update is a partial one. This will always be false and can be ignored

deprecated:


<Optional> snapshotโ€‹

โ— snapshot: undefined | string

The id of the snapshot if available.


<Optional> urlโ€‹

โ— url: undefined | string

The url to fetch the manifest of files in the update.



IAppInfoโ€‹

IAppInfo:

Information about the application.

binaryVersionCodeโ€‹

โ— binaryVersionCode: string | number

The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.


binaryVersionNameโ€‹

โ— binaryVersionName: string

The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.


bundleNameโ€‹

โ— bundleName: string

The bundle name.


bundleVersionโ€‹

โ— bundleVersion: string

deprecated: The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.


dataDirectoryโ€‹

โ— dataDirectory: string

Directory where the snapshots are stored


deviceโ€‹

โ— device: string

A generated device ID (NOT a native device ID)


platformโ€‹

โ— platform: "ios" | "android"

The platform that the app is currently installed on.


platformVersionโ€‹

โ— platformVersion: string

The version of the native platform.


versionโ€‹

โ— version: string

deprecated: The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.



ICurrentConfigโ€‹

ICurrentConfig:

The current configuration for the SDK on the device.

appIdโ€‹

โ— appId: string

The Ionic Appflow app id.


binaryVersionโ€‹

โ— binaryVersion: string

deprecated: The binary version of the native bundle versionName on Android or CFBundleShortVersionString on iOS deprecated in favor of versionName


binaryVersionCodeโ€‹

โ— binaryVersionCode: string

The build version code of the native bundle versionCode on Android or CFBundleVersion on iOS


binaryVersionNameโ€‹

โ— binaryVersionName: string

The binary version of the native bundle versionName on Android or CFBundleShortVersionString on iOS


channelโ€‹

โ— channel: string

The channel that the SDK should listen for updates on.


<Optional> currentBuildIdโ€‹

โ— currentBuildId: undefined | string

The id of the currently applied build or undefined if none is applied.


<Optional> currentVersionIdโ€‹

โ— currentVersionId: undefined | string

The id of the currently applied updated or undefined if none is applied.


disabledโ€‹

โ— disabled: boolean

Whether the user disabled deploy updates or not.


hostโ€‹

โ— host: string

The host API the SDK is configured to check for updates from.


maxVersionsโ€‹

โ— maxVersions: number

The maximum number of updates to be stored locally on the device.


minBackgroundDurationโ€‹

โ— minBackgroundDuration: number

The number of seconds the app needs to be in the background before the SDK considers it closed for the purposes of fetching and applying a new update.


updateMethodโ€‹

โ— updateMethod: "none" | "auto" | "background"

The currently configured updateMethod for the SDK.



IDeployConfigโ€‹

IDeployConfig:

The configuration for the SDK on the device.

<Optional> appIdโ€‹

โ— appId: undefined | string

The Ionic app id.


<Optional> channelโ€‹

โ— channel: undefined | string

The channel that the SDK should listen for updates on.


<Optional> debugโ€‹

โ— debug: undefined | false | true

Whether the app should run in debug mode


<Optional> maxVersionsโ€‹

โ— maxVersions: undefined | number

The number of previous updates to be cached on the device


<Optional> minBackgroundDurationโ€‹

โ— minBackgroundDuration: undefined | number

The number of seconds the app should be in the background for before the SDK considers it closed and checks for an updated on resume of the app.


<Optional> updateMethodโ€‹

โ— updateMethod: "none" | "auto" | "background"

The update method the app should use when checking for available updates



ISnapshotInfoโ€‹

ISnapshotInfo:

Information about a snapshot

binaryVersionโ€‹

โ— binaryVersion: string

deprecated: The binary version the snapshot was downloaded for. The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.


binaryVersionCodeโ€‹

โ— binaryVersionCode: string

The binary version build code the snapshot was downloaded for. The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.


binaryVersionNameโ€‹

โ— binaryVersionName: string

The binary version name the snapshot was downloaded for. The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.


binary_versionโ€‹

โ— binary_version: string

deprecated: in favor of binaryVersion

The binary version the snapshot was downloaded for.


buildIdโ€‹

โ— buildId: string

The id for the snapshot.


channelโ€‹

โ— channel: string

The channel that the snapshot was downloaded for..


deploy_uuidโ€‹

โ— deploy_uuid: string

deprecated: in favor of versionId

The id for the snapshot.


versionIdโ€‹

โ— versionId: string

The id for the snapshot.



ISyncOptionsโ€‹

ISyncOptions:

Configuration options for the call to sync

<Optional> updateMethodโ€‹

โ— updateMethod: "background" | "auto"

Whether the update should be applied immediately or on the next app start.