Improve this doc

$ ionic plugin add cordova-plugin-code-push


CodePush plugin for Cordova by Microsoft that supports iOS and Android.

For more info, please see

Supported platforms


import { CodePush } from 'ionic-native';

// note - mostly error & completed methods of observable will not fire
// as syncStatus will contain the current state of the update
CodePush.sync().subscribe((syncStatus) => console.log(syncStatus));

const downloadProgress = (progress) => { console.log(`Downloaded ${progress.receivedBytes} of ${progress.totalBytes}`); }
CodePush.sync({}, downloadProgress).subscribe((syncStatus) => console.log(syncStatus));

Static Members

getCurrentPackage(packageSuccess, packageError)

Get the current package information.

Param Type Details

Callback invoked with the currently deployed package information.


Optional callback invoked in case of an error.

Returns: Promise<ILocalPackage>


Gets the pending package information, if any. A pending package is one that has been installed but the application still runs the old code. This happends only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.

Returns: Promise<ILocalPackage>

checkForUpdate(querySuccess, queryError, deploymentKey)

Checks with the CodePush server if an update package is available for download.

Param Type Details

Callback invoked in case of a successful response from the server. The callback takes one RemotePackage parameter. A non-null package is a valid update. A null package means the application is up to date for the current native application version.


Optional callback invoked in case of an error.


Optional deployment key that overrides the config.xml setting.

Returns: Promise<IRemotePackage>

notifyApplicationReady(notifySucceeded, notifyFailed)

Notifies the plugin that the update operation succeeded and that the application is ready. Calling this function is required on the first run after an update. On every subsequent application run, calling this function is a noop. If using sync API, calling this function is not required since sync calls it internally.

Param Type Details

Optional callback invoked if the plugin was successfully notified.


Optional callback invoked in case of an error during notifying the plugin.

Returns: Promise<void>


Reloads the application. If there is a pending update package installed using ON_NEXT_RESTART or ON_NEXT_RESUME modes, the update will be immediately visible to the user. Otherwise, calling this function will simply reload the current version of the application.

Returns: Promise<void>

sync(syncCallback, syncOptions, downloadProgress)

Convenience method for installing updates in one method call. This method is provided for simplicity, and its behavior can be replicated by using window.codePush.checkForUpdate(), RemotePackage’s download() and LocalPackage’s install() methods.

The algorithm of this method is the following: - Checks for an update on the CodePush server. - If an update is available - If the update is mandatory and the alertMessage is set in options, the user will be informed that the application will be updated to the latest version. The update package will then be downloaded and applied. - If the update is not mandatory and the confirmMessage is set in options, the user will be asked if they want to update to the latest version. If they decline, the syncCallback will be invoked with SyncStatus.UPDATE_IGNORED. - Otherwise, the update package will be downloaded and applied with no user interaction. - If no update is available on the server, or if a previously rolled back update is available and the ignoreFailedUpdates is set to true, the syncCallback will be invoked with the SyncStatus.UP_TO_DATE. - If an error occurs during checking for update, downloading or installing it, the syncCallback will be invoked with the SyncStatus.ERROR.

Param Type Details

Optional callback to be called with the status of the sync operation.


Optional SyncOptions parameter configuring the behavior of the sync operation.


Optional callback invoked during the download process. It is called several times with one DownloadProgress parameter.

Returns: Observable<SyncStatus>