title | description | sidebar | ||
---|---|---|---|---|
Functions and settings |
All available method and settings of the plugin |
|
See the Github Readme for more information.
CapacitorUpdater can be configured with these 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/updates |
|
channelUrl |
string |
Configure the URL / endpoint for channel operations. Only available for Android and iOS. | https://api.capgo.app/channel_self |
|
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 |
|
publicKey |
string |
Configure the public key for end to end live update encryption Version 2 Only available for Android and iOS. | undefined |
6.2.0 |
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 |
localApi |
string |
Configure the CLI to use a local api for testing. | undefined |
6.3.3 |
localApiFiles |
string |
Configure the CLI to use a local file api for testing. | undefined |
6.3.3 |
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 |
appId |
string |
Configure the app id for the app in the config. | undefined |
6.0.0 |
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,
"channelUrl": https://example.com/api/channel,
"statsUrl": https://example.com/api/stats,
"privateKey": undefined,
"publicKey": undefined,
"version": undefined,
"directUpdate": undefined,
"periodCheckDelay": undefined,
"localS3": undefined,
"localHost": undefined,
"localWebHost": undefined,
"localSupa": undefined,
"localSupaAnon": undefined,
"localApi": undefined,
"localApiFiles": undefined,
"allowModifyUrl": undefined,
"defaultChannel": undefined,
"appId": 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,
channelUrl: https://example.com/api/channel,
statsUrl: https://example.com/api/stats,
privateKey: undefined,
publicKey: undefined,
version: undefined,
directUpdate: undefined,
periodCheckDelay: undefined,
localS3: undefined,
localHost: undefined,
localWebHost: undefined,
localSupa: undefined,
localSupaAnon: undefined,
localApi: undefined,
localApiFiles: undefined,
allowModifyUrl: undefined,
defaultChannel: undefined,
appId: undefined,
},
},
};
export default config;
notifyAppReady()
setUpdateUrl(...)
setStatsUrl(...)
setChannelUrl(...)
download(...)
next(...)
set(...)
delete(...)
list()
reset(...)
current()
reload()
setMultiDelay(...)
cancelDelay()
getLatest()
setChannel(...)
unsetChannel(...)
getChannel()
setCustomId(...)
getBuiltinVersion()
getDeviceId()
getPluginVersion()
isAutoUpdateEnabled()
removeAllListeners()
addListener('download', ...)
addListener('noNeedUpdate', ...)
addListener('updateAvailable', ...)
addListener('downloadComplete', ...)
addListener('majorAvailable', ...)
addListener('updateFailed', ...)
addListener('downloadFailed', ...)
addListener('appReloaded', ...)
addListener('appReady', ...)
- Interfaces
- Type Aliases
notifyAppReady() => Promise<AppReadyResult>
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<AppReadyResult>
setUpdateUrl(options: UpdateUrl) => Promise<void>
Set the updateUrl for the app, this will be used to check for updates.
Param | Type | Description |
---|---|---|
options |
UpdateUrl |
contains the URL to use for checking for updates. |
Since: 5.4.0
setStatsUrl(options: StatsUrl) => Promise<void>
Set the statsUrl for the app, this will be used to send statistics. Passing an empty string will disable statistics gathering.
Param | Type | Description |
---|---|---|
options |
StatsUrl |
contains the URL to use for sending statistics. |
Since: 5.4.0
setChannelUrl(options: ChannelUrl) => Promise<void>
Set the channelUrl for the app, this will be used to set the channel.
Param | Type | Description |
---|---|---|
options |
ChannelUrl |
contains the URL to use for setting the channel. |
Since: 5.4.0
download(options: DownloadOptions) => 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
Param | Type | Description |
---|---|---|
options |
DownloadOptions |
The {@link DownloadOptions} for downloading a new bundle zip. |
Returns: Promise<BundleInfo>
next(options: BundleId) => Promise<BundleInfo>
Set the next bundle to be used when the app is reloaded.
Param | Type | Description |
---|---|---|
options |
BundleId |
Contains the ID of the next Bundle to set on next app launch. {@link BundleInfo.id} |
Returns: Promise<BundleInfo>
set(options: BundleId) => Promise<void>
Set the current bundle and immediately reloads the app.
Param | Type | Description |
---|---|---|
options |
BundleId |
A {@link BundleId} object containing the new bundle id to set as current. |
delete(options: BundleId) => Promise<void>
Deletes the specified bundle from the native app storage. Use with {@link list} to get the stored Bundle IDs.
Param | Type | Description |
---|---|---|
options |
BundleId |
A {@link BundleId} object containing the ID of a bundle to delete (note, this is the bundle id, NOT the version name) |
list() => Promise<BundleListResult>
Get all locally downloaded bundles in your app
Returns: Promise<BundleListResult>
reset(options?: ResetOptions | undefined) => Promise<void>
Reset the app to the builtin
bundle (the one sent to Apple App Store / Google Play Store ) or the last successfully loaded bundle.
Param | Type | Description |
---|---|---|
options |
ResetOptions |
Containing {@link ResetOptions.toLastSuccessful}, true resets to the builtin bundle and false will reset to the last successfully loaded bundle. |
current() => Promise<CurrentBundleResult>
Get the current bundle, if none are set it returns builtin
. currentNative is the original bundle installed on the device
Returns: Promise<CurrentBundleResult>
reload() => Promise<void>
Reload the view
setMultiDelay(options: MultiDelayConditions) => Promise<void>
Sets a {@link DelayCondition} array containing conditions that the Plugin will use to delay the update.
After all conditions are met, the update process will run start again as usual, so update will be installed after a backgrounding or killing the app.
For the date
kind, the value should be an iso8601 date string.
For the background
kind, the value should be a number in milliseconds.
For the nativeVersion
kind, the value should be the version number.
For the kill
kind, the value is not used.
The function has unconsistent behavior the option kill do trigger the update after the first kill and not after the next background like other options. This will be fixed in a future major release.
Param | Type | Description |
---|---|---|
options |
MultiDelayConditions |
Containing the {@link MultiDelayConditions} array of conditions to set |
Since: 4.3.0
cancelDelay() => Promise<void>
Cancels a {@link DelayCondition} to process an update immediately.
Since: 4.0.0
getLatest() => Promise<LatestVersion>
Get Latest bundle available from update Url
Returns: Promise<LatestVersion>
Since: 4.0.0
setChannel(options: SetChannelOptions) => Promise<ChannelRes>
Sets the channel for this device. The channel has to allow for self assignment for this to work.
Do not use this method to set the channel at boot when autoUpdate
is enabled in the {@link PluginsConfig}.
This method is to set the channel after the app is ready.
Param | Type | Description |
---|---|---|
options |
SetChannelOptions |
Is the {@link SetChannelOptions} channel to set |
Returns: Promise<ChannelRes>
Since: 4.7.0
unsetChannel(options: UnsetChannelOptions) => Promise<void>
Unset the channel for this device. The device will then return to the default channel
Param | Type |
---|---|
options |
UnsetChannelOptions |
Since: 4.7.0
getChannel() => Promise<GetChannelRes>
Get the channel for this device
Returns: Promise<GetChannelRes>
Since: 4.8.0
setCustomId(options: SetCustomIdOptions) => Promise<void>
Set a custom ID for this device
Param | Type | Description |
---|---|---|
options |
SetCustomIdOptions |
is the {@link SetCustomIdOptions} customId to set |
Since: 4.9.0
getBuiltinVersion() => Promise<BuiltinVersion>
Get the native app version or the builtin version if set in config
Returns: Promise<BuiltinVersion>
Since: 5.2.0
getDeviceId() => Promise<DeviceId>
Get unique ID used to identify device (sent to auto update server)
Returns: Promise<DeviceId>
getPluginVersion() => Promise<PluginVersion>
Get the native Capacitor Updater plugin version (sent to auto update server)
Returns: Promise<PluginVersion>
isAutoUpdateEnabled() => Promise<AutoUpdateEnabled>
Get the state of auto update config.
Returns: Promise<AutoUpdateEnabled>
removeAllListeners() => Promise<void>
Remove all listeners for this plugin.
Since: 1.0.0
addListener(eventName: "download", listenerFunc: (state: DownloadEvent) => void) => Promise<PluginListenerHandle>
Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.
Param | Type |
---|---|
eventName |
'download' |
listenerFunc |
(state: DownloadEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 2.0.11
addListener(eventName: "noNeedUpdate", listenerFunc: (state: NoNeedEvent) => void) => Promise<PluginListenerHandle>
Listen for no need to update event, useful when you want force check every time the app is launched
Param | Type |
---|---|
eventName |
'noNeedUpdate' |
listenerFunc |
(state: NoNeedEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 4.0.0
addListener(eventName: "updateAvailable", listenerFunc: (state: UpdateAvailableEvent) => void) => Promise<PluginListenerHandle>
Listen for available update event, useful when you want to force check every time the app is launched
Param | Type |
---|---|
eventName |
'updateAvailable' |
listenerFunc |
(state: UpdateAvailableEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 4.0.0
addListener(eventName: "downloadComplete", listenerFunc: (state: DownloadCompleteEvent) => void) => Promise<PluginListenerHandle>
Listen for downloadComplete events.
Param | Type |
---|---|
eventName |
'downloadComplete' |
listenerFunc |
(state: DownloadCompleteEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 4.0.0
addListener(eventName: "majorAvailable", listenerFunc: (state: MajorAvailableEvent) => void) => Promise<PluginListenerHandle>
Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
Param | Type |
---|---|
eventName |
'majorAvailable' |
listenerFunc |
(state: MajorAvailableEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 2.3.0
addListener(eventName: "updateFailed", listenerFunc: (state: UpdateFailedEvent) => void) => Promise<PluginListenerHandle>
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 |
(state: UpdateFailedEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 2.3.0
addListener(eventName: "downloadFailed", listenerFunc: (state: DownloadFailedEvent) => void) => Promise<PluginListenerHandle>
Listen for download fail event in the App, let you know when a bundle download has failed
Param | Type |
---|---|
eventName |
'downloadFailed' |
listenerFunc |
(state: DownloadFailedEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 4.0.0
addListener(eventName: "appReloaded", listenerFunc: () => void) => Promise<PluginListenerHandle>
Listen for reload event in the App, let you know when reload has happened
Param | Type |
---|---|
eventName |
'appReloaded' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Since: 4.3.0
addListener(eventName: "appReady", listenerFunc: (state: AppReadyEvent) => void) => Promise<PluginListenerHandle>
Listen for app ready event in the App, let you know when app is ready to use
Param | Type |
---|---|
eventName |
'appReady' |
listenerFunc |
(state: AppReadyEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 5.1.0
Prop | Type |
---|---|
bundle |
BundleInfo |
Prop | Type |
---|---|
id |
string |
version |
string |
downloaded |
string |
checksum |
string |
status |
BundleStatus |
Prop | Type |
---|---|
url |
string |
Prop | Type |
---|---|
url |
string |
Prop | Type |
---|---|
url |
string |
Prop | Type | Description | Default | Since |
---|---|---|---|---|
url |
string |
The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.) | ||
version |
string |
The version code/name of this bundle/version | ||
sessionKey |
string |
The session key for the update | undefined |
4.0.0 |
checksum |
string |
The checksum for the update | undefined |
4.0.0 |
Prop | Type |
---|---|
id |
string |
Prop | Type |
---|---|
bundles |
BundleInfo[] |
Prop | Type |
---|---|
toLastSuccessful |
boolean |
Prop | Type |
---|---|
bundle |
BundleInfo |
native |
string |
Prop | Type |
---|---|
delayConditions |
DelayCondition[] |
Prop | Type | Description |
---|---|---|
kind |
DelayUntilNext |
Set up delay conditions in setMultiDelay |
value |
string |
Prop | Type | Description | Since |
---|---|---|---|
version |
string |
Result of getLatest method | 4.0.0 |
checksum |
string |
6 | |
major |
boolean |
||
message |
string |
||
sessionKey |
string |
||
error |
string |
||
old |
string |
||
url |
string |
||
manifest |
ManifestEntry[] |
6.1 |
Prop | Type |
---|---|
file_name |
string | null |
file_hash |
string | null |
download_url |
string | null |
Prop | Type | Description | Since |
---|---|---|---|
status |
string |
Current status of set channel | 4.7.0 |
error |
any |
||
message |
any |
Prop | Type |
---|---|
channel |
string |
triggerAutoUpdate |
boolean |
Prop | Type |
---|---|
triggerAutoUpdate |
boolean |
Prop | Type | Description | Since |
---|---|---|---|
channel |
string |
Current status of get channel | 4.8.0 |
error |
any |
||
message |
any |
||
status |
string |
||
allowSet |
boolean |
Prop | Type |
---|---|
customId |
string |
Prop | Type |
---|---|
version |
string |
Prop | Type |
---|---|
deviceId |
string |
Prop | Type |
---|---|
version |
string |
Prop | Type |
---|---|
enabled |
boolean |
Prop | Type |
---|---|
remove |
() => Promise<void> |
Prop | Type | Description | Since |
---|---|---|---|
percent |
number |
Current status of download, between 0 and 100. | 4.0.0 |
bundle |
BundleInfo |
Prop | Type | Description | Since |
---|---|---|---|
bundle |
BundleInfo |
Current status of download, between 0 and 100. | 4.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
bundle |
BundleInfo |
Current status of download, between 0 and 100. | 4.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
bundle |
BundleInfo |
Emit when a new update is available. | 4.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
version |
string |
Emit when a new major bundle is available. | 4.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
bundle |
BundleInfo |
Emit when a update failed to install. | 4.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
version |
string |
Emit when a download fail. | 4.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
bundle |
BundleInfo |
Emitted when the app is ready to use. | 5.2.0 |
status |
string |
"success" | "error" | "pending" | "downloading"
"background" | "kill" | "nativeVersion" | "date"