Plugin API
API
download(…)
Download a new version from the provided URL, it should be a zip file, with files inside or with a unique folder inside with all your files
Param | Type |
---|---|
options | { url: string; } |
Returns: Promise<{ version: string; }>
set(…)
Set version as current version, set will return an error if there are is no index.html file inside the version folder. versionName
is optional, and it’s a custom value that will be saved for you.
Param | Type |
---|---|
options | { version: string; versionName?: string; } |
getId()
Get unique ID used to identify device into auto-update server
Returns: Promise<{ id: string; }>
delete(…)
Delete version in storage
Param | Type |
---|---|
options | { version: string; } |
list()
Get all available versions
Returns: Promise<{ versions: string[]; }>
reset(…)
Set the builtin
version (the one sent to Apple Store / Google Play Store ) as the current version
Param | Type |
---|---|
options | { toAutoUpdate?: boolean; } |
current()
Get the current version, if none is set it returns builtin
, currentNative
is the original version install on the device
Returns: Promise<{ current: string; currentNative: string; }>
reload()
Reload the view
versionName()
Get the version name, if it was set during the set phase
Returns: Promise<{ versionName: string; }>
notifyAppReady()
Notify native plugin that the update is working, only in auto-update
delayUpdate()
Skip updates in the next time the app goes into the background, only in auto-update
cancelDelay()
allow update in the next time the app goes into the background, only in auto-update
Events
Listen to download events
On iOS, Apple doesn’t allow you to show a message when the app is updated, so you can’t show a progress bar.
Angular specific
You need to use ngZone to let the event be detected in angular
addListener(‘download’, …)
Listen for download event in the App, let you know when the download is started, loading and finished
Param | Type |
---|---|
eventName | 'download' |
listenerFunc | DownloadChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.0.11
addListener(‘majorAvailable’, …)
Listen for Major update events in the App, let you know when a major update is blocked by setting disableAutoUpdateBreaking
Param | Type |
---|---|
eventName | 'majorAvailable' |
listenerFunc | MajorAvailableListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.3.0
addListener(‘updateAvailable’, …)
Listen for update event in the App, and let you know when the update update is ready to install at the next app start
Param | Type |
---|---|
eventName | 'updateAvailable' |
listenerFunc | UpdateAvailableListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.3.0
addListener(string, …)
Param | Type |
---|---|
eventName | string |
listenerFunc | (...args: any[]) => any |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
Interfaces
PluginListenerHandle
Prop | Type |
---|---|
remove | () => Promise<void> |
DownloadEvent
Prop | Type | Description | Since |
---|---|---|---|
percent | number | Current status of download, between 0 and 100. | 2.0.11 |
MajorAvailableEvent
Prop | Type | Description | Since |
---|---|---|---|
version | string | Emit when a new major version is available. | 2.3.0 |
UpdateAvailableEvent
Prop | Type | Description | Since |
---|---|---|---|
version | string | Emit when a new update is available. | 3.0.0 |
Type Aliases
DownloadChangeListener
(state: DownloadEvent): void
MajorAvailableListener
(state: MajorAvailableEvent): void
UpdateAvailableListener
(state: UpdateAvailableEvent): void
Settings
After install capacitor-updater to your project, you can configure some behavior:
resetWhenUpdate
set it false to disable the reset version when updatingautoUpdateUrl
the target URL to get updatesautoUpdate
true or false depend on if you want manual or autostatsUrl
the target URL for stats, set it to "" to disable stats