Skip to content

Functions and settings

Updater Plugin Config

See the Github Readme for more information.

CapacitorUpdater can be configured with this options:

PropTypeDescriptionDefaultSince
appReadyTimeoutnumberConfigure the number of milliseconds the native plugin should wait before considering an update ‘failed’. Only available for Android and iOS.10000 // (10 seconds)
responseTimeoutnumberConfigure the number of milliseconds the native plugin should wait before considering API timeout. Only available for Android and iOS.20 // (20 second)
autoDeleteFailedbooleanConfigure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS.true
autoDeletePreviousbooleanConfigure whether the plugin should use automatically delete previous bundles after a successful update. Only available for Android and iOS.true
autoUpdatebooleanConfigure whether the plugin should use Auto Update via an update server. Only available for Android and iOS.true
resetWhenUpdatebooleanAutomatically delete previous downloaded bundles when a newer native app bundle is installed to the device. Only available for Android and iOS.true
updateUrlstringConfigure the URL / endpoint to which update checks are sent. Only available for Android and iOS.https://api.capgo.app/auto_update
statsUrlstringConfigure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting.https://api.capgo.app/stats
privateKeystringConfigure the private key for end to end live update encryption. Only available for Android and iOS.undefined
versionstringConfigure the current version of the app. This will be used for the first update request. If not set, the plugin will get the version from the native code. Only available for Android and iOS.undefined4.17.48
directUpdatebooleanMake the plugin direct install the update when the app what just updated/installed. Only for autoUpdate mode. Only available for Android and iOS.undefined5.1.0
periodCheckDelaynumberConfigure the delay period for period update check. the unit is in seconds. Only available for Android and iOS. Cannot be less than 600 seconds (10 minutes).600 // (10 minutes)
localS3booleanConfigure the CLI to use a local server for testing or self-hosted update server.undefined4.17.48
localHoststringConfigure the CLI to use a local server for testing or self-hosted update server.undefined4.17.48
localWebHoststringConfigure the CLI to use a local server for testing or self-hosted update server.undefined4.17.48
localSupastringConfigure the CLI to use a local server for testing or self-hosted update server.undefined4.17.48
localSupaAnonstringConfigure the CLI to use a local server for testing.undefined4.17.48
allowModifyUrlbooleanAllow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.false5.4.0
defaultChannelstringSet the default channel for the app in the config.undefined5.5.0

Examples

In capacitor.config.json:

{
"plugins": {
"CapacitorUpdater": {
"appReadyTimeout": 1000 // (1 second),
"responseTimeout": 10 // (10 second),
"autoDeleteFailed": false,
"autoDeletePrevious": false,
"autoUpdate": false,
"resetWhenUpdate": false,
"updateUrl": https://example.com/api/auto_update,
"statsUrl": https://example.com/api/stats,
"privateKey": undefined,
"version": undefined,
"directUpdate": undefined,
"periodCheckDelay": undefined,
"localS3": undefined,
"localHost": undefined,
"localWebHost": undefined,
"localSupa": undefined,
"localSupaAnon": undefined,
"allowModifyUrl": undefined,
"defaultChannel": undefined
}
}
}

In capacitor.config.ts:

/// <reference types="@capgo/capacitor-updater" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
CapacitorUpdater: {
appReadyTimeout: 1000, // (1 second)
responseTimeout: 10, // (10 second)
autoDeleteFailed: false,
autoDeletePrevious: false,
autoUpdate: false,
resetWhenUpdate: false,
updateUrl: https://example.com/api/auto_update,
statsUrl: https://example.com/api/stats,
privateKey: undefined,
version: undefined,
directUpdate: undefined,
periodCheckDelay: undefined,
localS3: undefined,
localHost: undefined,
localWebHost: undefined,
localSupa: undefined,
localSupaAnon: undefined,
allowModifyUrl: undefined,
defaultChannel: undefined,
},
},
};
export default config;

Methods

notifyAppReady()

notifyAppReady() => Promise<{ bundle: BundleInfo; }>

Notify Capacitor Updater that the current bundle is working (a rollback will occur if this method is not called on every app launch) By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur. Change this behaviour with {@link appReadyTimeout}

Returns: Promise<{ bundle: BundleInfo; }>


setUpdateUrl(…)

setUpdateUrl(options: { url: string; }) => Promise<void>

Set the updateUrl for the app, this will be used to check for updates.

ParamType
options{ url: string; }

Since: 5.4.0


setStatsUrl(…)

setStatsUrl(options: { url: string; }) => Promise<void>

Set the statsUrl for the app, this will be used to send statistics.

ParamType
options{ url: string; }

Since: 5.4.0


setChannelUrl(…)

setChannelUrl(options: { url: string; }) => Promise<void>

Set the channelUrl for the app, this will be used to set the channel.

ParamType
options{ url: string; }

Since: 5.4.0


download(…)

download(options: { url: string; version: string; sessionKey?: string; checksum?: string; }) => Promise<BundleInfo>

Download a new bundle from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files

ParamType
options{ url: string; version: string; sessionKey?: string; checksum?: string; }

Returns: Promise<BundleInfo>


next(…)

next(options: { id: string; }) => Promise<BundleInfo>

Set the next bundle to be used when the app is reloaded.

ParamType
options{ id: string; }

Returns: Promise<BundleInfo>


set(…)

set(options: { id: string; }) => Promise<void>

Set the current bundle and immediately reloads the app.

ParamType
options{ id: string; }

delete(…)

delete(options: { id: string; }) => Promise<void>

Delete bundle in storage

ParamType
options{ id: string; }

list()

list() => Promise<{ bundles: BundleInfo[]; }>

Get all locally downloaded bundles in your app

Returns: Promise<{ bundles: BundleInfo[]; }>


reset(…)

reset(options?: { toLastSuccessful?: boolean | undefined; } | undefined) => Promise<void>

Set the builtin bundle (the one sent to Apple store / Google play store ) as current bundle

ParamType
options{ toLastSuccessful?: boolean; }

current()

current() => Promise<{ bundle: BundleInfo; native: string; }>

Get the current bundle, if none are set it returns builtin, currentNative is the original bundle installed on the device

Returns: Promise<{ bundle: BundleInfo; native: string; }>


reload()

reload() => Promise<void>

Reload the view


setMultiDelay(…)

setMultiDelay(options: { delayConditions: DelayCondition[]; }) => Promise<void>

Set DelayCondition, skip updates until one of the conditions is met

ParamTypeDescription
options{ delayConditions: DelayCondition[]; }are the {@link DelayCondition} list to set

Since: 4.3.0


cancelDelay()

cancelDelay() => Promise<void>

Cancel delay to updates as usual

Since: 4.0.0


getLatest()

getLatest() => Promise<latestVersion>

Get Latest bundle available from update Url

Returns: Promise<latestVersion>

Since: 4.0.0


setChannel(…)

setChannel(options: SetChannelOptions) => Promise<channelRes>

Set Channel for this device, the channel have to allow self assignement to make this work Do not use this method to set the channel at boot when autoUpdate is enabled, this method is made to set the channel after the app is ready when user click on a button for example

ParamTypeDescription
optionsSetChannelOptionsis the {@link SetChannelOptions} channel to set

Returns: Promise<channelRes>

Since: 4.7.0


unsetChannel(…)

unsetChannel(options: UnsetChannelOptions) => Promise<void>

Unset Channel for this device, the device will return to the default channel

ParamType
optionsUnsetChannelOptions

Since: 4.7.0


getChannel()

getChannel() => Promise<getChannelRes>

get Channel for this device

Returns: Promise<getChannelRes>

Since: 4.8.0


setCustomId(…)

setCustomId(options: SetCustomIdOptions) => Promise<void>

Set Channel for this device

ParamTypeDescription
optionsSetCustomIdOptionsis the {@link SetCustomIdOptions} customId to set

Since: 4.9.0


addListener(‘download’, …)

addListener(eventName: "download", listenerFunc: DownloadChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for download event in the App, let you know when the download is started, loading and finished, with a percent value

ParamType
eventName’download’
listenerFuncDownloadChangeListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 2.0.11


addListener(‘noNeedUpdate’, …)

addListener(eventName: "noNeedUpdate", listenerFunc: NoNeedListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for no need to update event, usefull when you want force check every time the app is launched

ParamType
eventName’noNeedUpdate’
listenerFuncNoNeedListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 4.0.0


addListener(‘updateAvailable’, …)

addListener(eventName: "updateAvailable", listenerFunc: UpdateAvailabledListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for availbale update event, usefull when you want to force check every time the app is launched

ParamType
eventName’updateAvailable’
listenerFuncUpdateAvailabledListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 4.0.0


addListener(‘downloadComplete’, …)

addListener(eventName: "downloadComplete", listenerFunc: DownloadCompleteListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for download event in the App, let you know when the download is started, loading and finished

ParamType
eventName’downloadComplete’
listenerFuncDownloadCompleteListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 4.0.0


addListener(‘majorAvailable’, …)

addListener(eventName: "majorAvailable", listenerFunc: MajorAvailableListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking

ParamType
eventName’majorAvailable’
listenerFuncMajorAvailableListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 2.3.0


addListener(‘updateFailed’, …)

addListener(eventName: "updateFailed", listenerFunc: UpdateFailedListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for update fail event in the App, let you know when update has fail to install at next app start

ParamType
eventName’updateFailed’
listenerFuncUpdateFailedListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 2.3.0


addListener(‘downloadFailed’, …)

addListener(eventName: "downloadFailed", listenerFunc: DownloadFailedListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for download fail event in the App, let you know when download has fail finished

ParamType
eventName’downloadFailed’
listenerFuncDownloadFailedListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 4.0.0


addListener(‘appReloaded’, …)

addListener(eventName: "appReloaded", listenerFunc: AppReloadedListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for reload event in the App, let you know when reload has happend

ParamType
eventName’appReloaded’
listenerFuncAppReloadedListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 4.3.0


addListener(‘appReady’, …)

addListener(eventName: "appReady", listenerFunc: AppReadyListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for app ready event in the App, let you know when app is ready to use

ParamType
eventName’appReady’
listenerFuncAppReadyListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 5.1.0


getBuiltinVersion()

getBuiltinVersion() => Promise<{ version: string; }>

Get the native app version or the builtin version if set in config

Returns: Promise<{ version: string; }>

Since: 5.2.0


getDeviceId()

getDeviceId() => Promise<{ deviceId: string; }>

Get unique ID used to identify device (sent to auto update server)

Returns: Promise<{ deviceId: string; }>


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor Updater plugin version (sent to auto update server)

Returns: Promise<{ version: string; }>


isAutoUpdateEnabled()

isAutoUpdateEnabled() => Promise<{ enabled: boolean; }>

Get the state of auto update config. This will return false in manual mode.

Returns: Promise<{ enabled: boolean; }>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 1.0.0


Interfaces

BundleInfo

PropType
idstring
versionstring
downloadedstring
checksumstring
statusBundleStatus

DelayCondition

PropTypeDescription
kindDelayUntilNextSet up delay conditions in setMultiDelay
valuestring

latestVersion

PropTypeDescriptionSince
versionstringRes of getLatest method4.0.0
majorboolean
messagestring
sessionKeystring
errorstring
oldstring
urlstring

channelRes

PropTypeDescriptionSince
statusstringCurrent status of set channel4.7.0
errorany
messageany

SetChannelOptions

PropType
channelstring
triggerAutoUpdateboolean

UnsetChannelOptions

PropType
triggerAutoUpdateboolean

getChannelRes

PropTypeDescriptionSince
channelstringCurrent status of get channel4.8.0
errorany
messageany
statusstring
allowSetboolean

SetCustomIdOptions

PropType
customIdstring

PluginListenerHandle

PropType
remove() => Promise<void>

DownloadEvent

PropTypeDescriptionSince
percentnumberCurrent status of download, between 0 and 100.4.0.0
bundleBundleInfo

noNeedEvent

PropTypeDescriptionSince
bundleBundleInfoCurrent status of download, between 0 and 100.4.0.0

updateAvailableEvent

PropTypeDescriptionSince
bundleBundleInfoCurrent status of download, between 0 and 100.4.0.0

DownloadCompleteEvent

PropTypeDescriptionSince
bundleBundleInfoEmit when a new update is available.4.0.0

MajorAvailableEvent

PropTypeDescriptionSince
versionstringEmit when a new major bundle is available.4.0.0

UpdateFailedEvent

PropTypeDescriptionSince
bundleBundleInfoEmit when a update failed to install.4.0.0

DownloadFailedEvent

PropTypeDescriptionSince
versionstringEmit when a download fail.4.0.0

AppReadyEvent

PropTypeDescriptionSince
bundleBundleInfoEmit when a app is ready to use.5.2.0
statusstring

Type Aliases

BundleStatus

”success” | “error” | “pending” | “downloading”

DelayUntilNext

”background” | “kill” | “nativeVersion” | “date”

DownloadChangeListener

(state: DownloadEvent): void

NoNeedListener

(state: noNeedEvent): void

UpdateAvailabledListener

(state: updateAvailableEvent): void

DownloadCompleteListener

(state: DownloadCompleteEvent): void

MajorAvailableListener

(state: MajorAvailableEvent): void

UpdateFailedListener

(state: UpdateFailedEvent): void

DownloadFailedListener

(state: DownloadFailedEvent): void

AppReloadedListener

(state: void): void

AppReadyListener

(state: AppReadyEvent): void