Skip to content

Commit 0de0534

Browse files
committed
1 parent 613f1d2 commit 0de0534

1 file changed

Lines changed: 66 additions & 8 deletions

File tree

  • src/content/docs/docs/plugin

‎src/content/docs/docs/plugin/api.md‎

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CapacitorUpdater can be configured with these options:
2222
| **`resetWhenUpdate`** | `boolean` | Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device. Setting this to false can broke the auto update flow if the user download from the store a native app bundle that is older than the current downloaded bundle. Upload will be prevented by channel setting downgrade_under_native. Only available for Android and iOS. | `true` | |
2323
| **`updateUrl`** | `string` | Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS. | `https://plugin.capgo.app/updates` | |
2424
| **`channelUrl`** | `string` | Configure the URL / endpoint for channel operations. Only available for Android and iOS. | `https://plugin.capgo.app/channel_self` | |
25-
| **`statsUrl`** | `string` | Configure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting. Native stats include update lifecycle events, app health signals such as crashes, Android ANRs, low-memory exits, iOS memory warnings, and WebView health signals such as JavaScript errors, unhandled promise rejections, resource load failures, WebView renderer exits, unclean WebView restarts, app launch readiness timing, and WebView load milestones when available. | `https://plugin.capgo.app/stats` | |
25+
| **`statsUrl`** | `string` | Configure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting. Native stats include update lifecycle events, app health signals such as crashes, Android ANRs, low-memory exits, iOS memory warnings, and WebView health signals such as JavaScript errors, unhandled promise rejections, resource load failures, WebView renderer exits, unclean WebView restarts, app launch readiness timing, and WebView load milestones when available. Failed background update checks that never start a download (network errors, timeouts, non-2xx responses, unreadable payloads) are reported as `update_check_error` with `metadata.error` and optional `metadata.status_code`, not as `download_fail`. Self-hosted Capgo backends must allow the `update_check_error` stats action. | `https://plugin.capgo.app/stats` | |
2626
| **`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 |
2727
| **`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 |
2828
| **`directUpdate`** | `boolean \| 'always' \| 'atInstall' \| 'onLaunch'` | Configure when the plugin should direct install updates. Only for autoUpdate mode. Instant apply (`atInstall`, `onLaunch`, `always`) should be uploaded with `--delta` so the update does not slow the user experience. A full zip, especially over 10MB, is relatively slow for users. These modes require `autoSplashscreen: true` and `@capacitor/splash-screen` installed with `launchAutoHide: false`. This flag makes the CLI upload delta in CI and ask for confirmation in local uploads. - false: Never do direct updates - atInstall: Same as `"atInstall"` for {@link autoUpdate} - onLaunch: Same as `"onLaunch"` for {@link autoUpdate} - always: Same as `"always"` for {@link autoUpdate} - true: (deprecated) Same as "always" for backward compatibility | `false` | 5.1.0 |
@@ -54,6 +54,14 @@ CapacitorUpdater can be configured with these options:
5454
| **`shakeMenu`** | `boolean` | Enable the native preview menu gesture while a preview session is active. Outside preview sessions this preview menu is ignored, unless {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector} is enabled. | `false` | 7.5.0 |
5555
| **`shakeMenuGesture`** | `ShakeMenuGesture` | Choose which native gesture opens the preview/channel menu. This applies to both {@link PluginsConfig.CapacitorUpdater.shakeMenu} and {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}. Only available for Android and iOS. | `'shake'` | 8.48.0 |
5656
| **`allowShakeChannelSelector`** | `boolean` | Enable the native menu gesture to show a channel selector menu for switching between update channels. If {@link PluginsConfig.CapacitorUpdater.shakeMenu} is also enabled while a preview session is active, the shake menu includes both preview actions and channel switching. The native gesture can be changed with {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}. Only available for Android and iOS. | `false` | 8.43.0 |
57+
| **`nativeUpdatePrompt`** | `boolean` | When enabled, show a native dialog prompting the user to install a newer native app from the App Store or Play Store. The prompt appears when a live update is blocked because the device native app is too old, including backend `disable_auto_update_*` responses, `store_update_required`, and `breakingAvailable` / `majorAvailable` flows. Only available for Android and iOS. No-op on web. | `false` | 8.53.0 |
58+
| **`nativeUpdatePromptTitle`** | `string` | Optional title for the native store update dialog shown when {@link PluginsConfig.CapacitorUpdater.nativeUpdatePrompt} is enabled. Only available for Android and iOS. | `"Update available"` | 8.53.0 |
59+
| **`nativeUpdatePromptMessage`** | `string` | Optional message body for the native store update dialog shown when {@link PluginsConfig.CapacitorUpdater.nativeUpdatePrompt} is enabled. Only available for Android and iOS. | `A short message explaining that a newer native app is available in the store.` | 8.53.0 |
60+
| **`nativeUpdatePromptUpdateButton`** | `string` | Optional label for the primary action button that opens the store or starts an in-app update on Android. Only available for Android and iOS. | `"Update"` | 8.53.0 |
61+
| **`nativeUpdatePromptLaterButton`** | `string` | Optional label for the dismiss action on the native store update dialog. Only available for Android and iOS. | `"Not now"` | 8.53.0 |
62+
| **`nativeUpdatePromptCountry`** | `string` | Optional ISO 3166-1 alpha-2 country filter. When set, the prompt is shown only when the device region matches one of the comma-separated country codes (for example `"US"` or `"US,CA"`). Only available for Android and iOS. | `undefined (show in all regions)` | 8.53.0 |
63+
| **`nativeUpdatePromptOnStoreCheck`** | `boolean` | When {@link PluginsConfig.CapacitorUpdater.nativeUpdatePrompt} is enabled, also show the dialog when {@link CapacitorUpdaterPlugin.getAppUpdateInfo} reports that a store update is available. Only available for Android and iOS. | `false` | 8.53.0 |
64+
| **`nativeUpdatePromptCooldownHours`** | `number` | Minimum hours between native update prompts for the same native app version. Also limited to once per app session. Only available for Android and iOS. | `24` | 8.53.0 |
5765

5866

5967
</docgen-config>
@@ -99,6 +107,7 @@ CapacitorUpdater can be configured with these options:
99107
- [`getPluginVersion`](#getpluginversion)
100108
- [`isAutoUpdateEnabled`](#isautoupdateenabled)
101109
- [`removeAllListeners`](#removealllisteners)
110+
- [`addListener('updaterEvent')`](#addlistenerupdaterevent)
102111
- [`addListener('download')`](#addlistenerdownload)
103112
- [`addListener('noNeedUpdate')`](#addlistenernoneedupdate)
104113
- [`addListener('updateCheckResult')`](#addlistenerupdatecheckresult)
@@ -818,16 +827,17 @@ setMultiDelay(options: MultiDelayConditions) => Promise<void>
818827
Configure conditions that must be met before a pending update is applied.
819828

820829
After calling {@link next} to queue an update, use this method to control when it gets applied.
821-
The update will only be installed after ALL specified conditions are satisfied.
830+
By default, the update is installed only after **all** specified conditions are satisfied (`conditionMode: 'and'`).
831+
Set `conditionMode` to `'or'` to apply the update as soon as **any** condition is met.
822832

823833
Available condition types:
824-
- `background`: Wait for the app to be backgrounded. Optionally specify duration in milliseconds.
825-
- `kill`: Wait for the app to be killed and relaunched (**Note:** Current behavior triggers update immediately on kill, not on next background. This will be fixed in v8.)
834+
- `background`: Wait until the app has spent more than the configured time in the background (see value formats below).
835+
- `kill`: The condition clears on the next launch and can also clear during Android activity destruction; activity destruction does not prove that the app process ended. Automatic installation waits for the next background, because it runs from appMovedToBackground. Calling {@link reload} can apply the pending bundle immediately.
826836
- `date`: Wait until a specific date/time (ISO 8601 format)
827837
- `nativeVersion`: Wait until the native app is updated to a specific version
828838

829839
Condition value formats:
830-
- `background`: Number in milliseconds (e.g., `"300000"` for 5 minutes), or omit for immediate
840+
- `background`: Time in milliseconds in background must exceed this value before the condition can clear on return to foreground (e.g., `"300000"` for more than 5 minutes; exactly `300000` ms does not clear). Omit `value` or use `"0"` to clear after one background-and-return cycle; the update installs on the following background.
831841
- `kill`: No value needed
832842
- `date`: ISO 8601 date string (e.g., `"2025-12-31T23:59:59Z"`)
833843
- `nativeVersion`: Version string (e.g., `"2.0.0"`)
@@ -849,8 +859,9 @@ Condition value formats:
849859
**Example**
850860

851861
```ts
852-
// Update after user kills app OR after 5 minutes in background
862+
// Update after kill condition clears on launch AND background time exceeds 5 minutes
853863
await CapacitorUpdater.setMultiDelay({
864+
conditionMode: 'or',
854865
delayConditions: [
855866
{ kind: 'kill' },
856867
{ kind: 'background', value: '300000' }
@@ -870,7 +881,7 @@ await CapacitorUpdater.setMultiDelay({
870881
**Example**
871882

872883
```ts
873-
// Default behavior: update on next background
884+
// One background-and-return clears the condition; update installs on the next background
874885
await CapacitorUpdater.setMultiDelay({
875886
delayConditions: [{ kind: 'background' }]
876887
});
@@ -1430,6 +1441,7 @@ removeAllListeners() => Promise<void>
14301441
Remove all event listeners registered for this plugin.
14311442

14321443
This unregisters all listeners added via {@link addListener} for all event types:
1444+
- `updaterEvent`
14331445
- `download`
14341446
- `noNeedUpdate`
14351447
- `updateCheckResult`
@@ -1454,6 +1466,51 @@ to prevent memory leaks from lingering event listeners.
14541466
--------------------
14551467

14561468

1469+
### addListener('updaterEvent')
1470+
1471+
```typescript
1472+
addListener(eventName: 'updaterEvent', listenerFunc: (event: UpdaterEvent) => void) => Promise<PluginListenerHandle>
1473+
```
1474+
1475+
Listen for every updater event with a single listener.
1476+
1477+
Each call receives `{ type, data }`: `type` is the event name (`download`, `updateAvailable`,
1478+
`downloadFailed`, `appReady`, ...) and `data` is the payload the matching legacy listener receives.
1479+
When the native layer retains an event until a listener attaches (for example `set` and `appReady`),
1480+
`updaterEvent` gets the same retention.
1481+
1482+
The per-event listeners below are deprecated and will be removed in v9.
1483+
1484+
```typescript
1485+
CapacitorUpdater.addListener('updaterEvent', (event) => {
1486+
switch (event.type) {
1487+
case 'download':
1488+
console.log('progress', event.data.percent);
1489+
break;
1490+
case 'downloadFailed':
1491+
console.warn('download failed', event.data.version);
1492+
break;
1493+
}
1494+
});
1495+
```
1496+
1497+
**Parameters**
1498+
1499+
| Name | Type | Description |
1500+
| --- | --- | --- |
1501+
| `eventName` | `'updaterEvent'` | |
1502+
| `listenerFunc` | `(event: UpdaterEvent) => void` | |
1503+
1504+
**Returns**
1505+
1506+
`Promise<PluginListenerHandle>`
1507+
1508+
**Since:** 8.53.0
1509+
1510+
1511+
--------------------
1512+
1513+
14571514
### addListener('download')
14581515

14591516
```typescript
@@ -1516,7 +1573,8 @@ The backend can classify the UpdateCheckResultEvent payload as `up_to_date`, `bl
15161573

15171574
This event is emitted alongside legacy events. For `up_to_date` and `blocked`, it is emitted before
15181575
`noNeedUpdate` and does not emit `downloadFailed`. For `failed`, it is emitted before the legacy
1519-
`downloadFailed` event and keeps the existing failure stats behavior.
1576+
`downloadFailed` event; native code also sends an `update_check_error` stat (with error metadata)
1577+
instead of `download_fail`, because no bundle download was attempted.
15201578

15211579
**Parameters**
15221580

0 commit comments

Comments
 (0)