Functions and settings
Updater Plugin Config
See the Github Readme for more information.
CapacitorUpdater can be configured with this options:
Prop | Type | Description | Default | Since |
---|---|---|---|---|
appReadyTimeout | number | Configure the number of milliseconds the native plugin should wait before considering an update ‘failed’. Only available for Android and iOS. | 10000 // (10 seconds) | |
responseTimeout | number | Configure the number of milliseconds the native plugin should wait before considering API timeout. Only available for Android and iOS. | 20 // (20 second) | |
autoDeleteFailed | boolean | Configure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS. | true | |
autoDeletePrevious | boolean | Configure whether the plugin should use automatically delete previous bundles after a successful update. Only available for Android and iOS. | true | |
autoUpdate | boolean | Configure whether the plugin should use Auto Update via an update server. Only available for Android and iOS. | true | |
resetWhenUpdate | boolean | Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device. Only available for Android and iOS. | true | |
updateUrl | string | Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS. | https://api.capgo.app/auto_update | |
statsUrl | string | Configure 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 | |
privateKey | string | Configure the private key for end to end live update encryption. Only available for Android and iOS. | undefined | |
version | string | Configure 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. | undefined | 4.17.48 |
directUpdate | boolean | Make the plugin direct install the update when the app what just updated/installed. Only for autoUpdate mode. Only available for Android and iOS. | undefined | 5.1.0 |
periodCheckDelay | number | Configure 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) | |
localS3 | boolean | Configure the CLI to use a local server for testing or self-hosted update server. | undefined | 4.17.48 |
localHost | string | Configure the CLI to use a local server for testing or self-hosted update server. | undefined | 4.17.48 |
localWebHost | string | Configure the CLI to use a local server for testing or self-hosted update server. | undefined | 4.17.48 |
localSupa | string | Configure the CLI to use a local server for testing or self-hosted update server. | undefined | 4.17.48 |
localSupaAnon | string | Configure the CLI to use a local server for testing. | undefined | 4.17.48 |
allowModifyUrl | boolean | Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side. | false | 5.4.0 |
defaultChannel | string | Set the default channel for the app in the config. | undefined | 5.5.0 |
Examples
In capacitor.config.json
:
In capacitor.config.ts
:
notifyAppReady()
setUpdateUrl(...)
setStatsUrl(...)
setChannelUrl(...)
download(...)
next(...)
set(...)
delete(...)
list()
reset(...)
current()
reload()
setMultiDelay(...)
cancelDelay()
getLatest()
setChannel(...)
unsetChannel(...)
getChannel()
setCustomId(...)
addListener('download', ...)
addListener('noNeedUpdate', ...)
addListener('updateAvailable', ...)
addListener('downloadComplete', ...)
addListener('majorAvailable', ...)
addListener('updateFailed', ...)
addListener('downloadFailed', ...)
addListener('appReloaded', ...)
addListener('appReady', ...)
getBuiltinVersion()
getDeviceId()
getPluginVersion()
isAutoUpdateEnabled()
removeAllListeners()
- Interfaces
- Type Aliases
Methods
notifyAppReady()
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(…)
Set the updateUrl for the app, this will be used to check for updates.
Param | Type |
---|---|
options | { url: string; } |
Since: 5.4.0
setStatsUrl(…)
Set the statsUrl for the app, this will be used to send statistics.
Param | Type |
---|---|
options | { url: string; } |
Since: 5.4.0
setChannelUrl(…)
Set the channelUrl for the app, this will be used to set the channel.
Param | Type |
---|---|
options | { url: string; } |
Since: 5.4.0
download(…)
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
Param | Type |
---|---|
options | { url: string; version: string; sessionKey?: string; checksum?: string; } |
Returns: Promise<BundleInfo>
next(…)
Set the next bundle to be used when the app is reloaded.
Param | Type |
---|---|
options | { id: string; } |
Returns: Promise<BundleInfo>
set(…)
Set the current bundle and immediately reloads the app.
Param | Type |
---|---|
options | { id: string; } |
delete(…)
Delete bundle in storage
Param | Type |
---|---|
options | { id: string; } |
list()
Get all locally downloaded bundles in your app
Returns: Promise<{ bundles: BundleInfo[]; }>
reset(…)
Set the builtin
bundle (the one sent to Apple store / Google play store ) as current bundle
Param | Type |
---|---|
options | { toLastSuccessful?: boolean; } |
current()
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 the view
setMultiDelay(…)
Set DelayCondition, skip updates until one of the conditions is met
Param | Type | Description |
---|---|---|
options | { delayConditions: DelayCondition[]; } | are the {@link DelayCondition} list to set |
Since: 4.3.0
cancelDelay()
Cancel delay to updates as usual
Since: 4.0.0
getLatest()
Get Latest bundle available from update Url
Returns: Promise<latestVersion>
Since: 4.0.0
setChannel(…)
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
Param | Type | Description |
---|---|---|
options | SetChannelOptions | is the {@link SetChannelOptions} channel to set |
Returns: Promise<channelRes>
Since: 4.7.0
unsetChannel(…)
Unset Channel for this device, the device will return to the default channel
Param | Type |
---|---|
options | UnsetChannelOptions |
Since: 4.7.0
getChannel()
get Channel for this device
Returns: Promise<getChannelRes>
Since: 4.8.0
setCustomId(…)
Set Channel for this device
Param | Type | Description |
---|---|---|
options | SetCustomIdOptions | is the {@link SetCustomIdOptions} customId to set |
Since: 4.9.0
addListener(‘download’, …)
Listen for download event in the App, let you know when the download is started, loading and finished, with a percent value
Param | Type |
---|---|
eventName | ’download’ |
listenerFunc | DownloadChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.0.11
addListener(‘noNeedUpdate’, …)
Listen for no need to update event, usefull when you want force check every time the app is launched
Param | Type |
---|---|
eventName | ’noNeedUpdate’ |
listenerFunc | NoNeedListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 4.0.0
addListener(‘updateAvailable’, …)
Listen for availbale update event, usefull when you want to force check every time the app is launched
Param | Type |
---|---|
eventName | ’updateAvailable’ |
listenerFunc | UpdateAvailabledListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 4.0.0
addListener(‘downloadComplete’, …)
Listen for download event in the App, let you know when the download is started, loading and finished
Param | Type |
---|---|
eventName | ’downloadComplete’ |
listenerFunc | DownloadCompleteListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 4.0.0
addListener(‘majorAvailable’, …)
Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
Param | Type |
---|---|
eventName | ’majorAvailable’ |
listenerFunc | MajorAvailableListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.3.0
addListener(‘updateFailed’, …)
Listen for update fail event in the App, let you know when update has fail to install at next app start
Param | Type |
---|---|
eventName | ’updateFailed’ |
listenerFunc | UpdateFailedListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.3.0
addListener(‘downloadFailed’, …)
Listen for download fail event in the App, let you know when download has fail finished
Param | Type |
---|---|
eventName | ’downloadFailed’ |
listenerFunc | DownloadFailedListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 4.0.0
addListener(‘appReloaded’, …)
Listen for reload event in the App, let you know when reload has happend
Param | Type |
---|---|
eventName | ’appReloaded’ |
listenerFunc | AppReloadedListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 4.3.0
addListener(‘appReady’, …)
Listen for app ready event in the App, let you know when app is ready to use
Param | Type |
---|---|
eventName | ’appReady’ |
listenerFunc | AppReadyListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 5.1.0
getBuiltinVersion()
Get the native app version or the builtin version if set in config
Returns: Promise<{ version: string; }>
Since: 5.2.0
getDeviceId()
Get unique ID used to identify device (sent to auto update server)
Returns: Promise<{ deviceId: string; }>
getPluginVersion()
Get the native Capacitor Updater plugin version (sent to auto update server)
Returns: Promise<{ version: string; }>
isAutoUpdateEnabled()
Get the state of auto update config. This will return false
in manual mode.
Returns: Promise<{ enabled: boolean; }>
removeAllListeners()
Remove all listeners for this plugin.
Since: 1.0.0
Interfaces
BundleInfo
Prop | Type |
---|---|
id | string |
version | string |
downloaded | string |
checksum | string |
status | BundleStatus |
DelayCondition
Prop | Type | Description |
---|---|---|
kind | DelayUntilNext | Set up delay conditions in setMultiDelay |
value | string |
latestVersion
Prop | Type | Description | Since |
---|---|---|---|
version | string | Res of getLatest method | 4.0.0 |
major | boolean | ||
message | string | ||
sessionKey | string | ||
error | string | ||
old | string | ||
url | string |
channelRes
Prop | Type | Description | Since |
---|---|---|---|
status | string | Current status of set channel | 4.7.0 |
error | any | ||
message | any |
SetChannelOptions
Prop | Type |
---|---|
channel | string |
triggerAutoUpdate | boolean |
UnsetChannelOptions
Prop | Type |
---|---|
triggerAutoUpdate | boolean |
getChannelRes
Prop | Type | Description | Since |
---|---|---|---|
channel | string | Current status of get channel | 4.8.0 |
error | any | ||
message | any | ||
status | string | ||
allowSet | boolean |
SetCustomIdOptions
Prop | Type |
---|---|
customId | string |
PluginListenerHandle
Prop | Type |
---|---|
remove | () => Promise<void> |
DownloadEvent
Prop | Type | Description | Since |
---|---|---|---|
percent | number | Current status of download, between 0 and 100. | 4.0.0 |
bundle | BundleInfo |
noNeedEvent
Prop | Type | Description | Since |
---|---|---|---|
bundle | BundleInfo | Current status of download, between 0 and 100. | 4.0.0 |
updateAvailableEvent
Prop | Type | Description | Since |
---|---|---|---|
bundle | BundleInfo | Current status of download, between 0 and 100. | 4.0.0 |
DownloadCompleteEvent
Prop | Type | Description | Since |
---|---|---|---|
bundle | BundleInfo | Emit when a new update is available. | 4.0.0 |
MajorAvailableEvent
Prop | Type | Description | Since |
---|---|---|---|
version | string | Emit when a new major bundle is available. | 4.0.0 |
UpdateFailedEvent
Prop | Type | Description | Since |
---|---|---|---|
bundle | BundleInfo | Emit when a update failed to install. | 4.0.0 |
DownloadFailedEvent
Prop | Type | Description | Since |
---|---|---|---|
version | string | Emit when a download fail. | 4.0.0 |
AppReadyEvent
Prop | Type | Description | Since |
---|---|---|---|
bundle | BundleInfo | Emit when a app is ready to use. | 5.2.0 |
status | string |
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