@capgo/capacitor-updater 8.45.10 → 8.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Package.swift CHANGED
@@ -11,7 +11,7 @@ let package = Package(
11
11
  ],
12
12
  dependencies: [
13
13
  .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
14
- .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.11.2")),
14
+ .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.12.0")),
15
15
  .package(url: "https://github.com/weichsel/ZIPFoundation.git", from: "0.9.20"),
16
16
  .package(url: "https://github.com/mrackwitz/Version.git", exact: "0.8.0"),
17
17
  .package(url: "https://github.com/attaswift/BigInt.git", from: "5.7.0")
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Capacitor updater
2
- <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
2
+ <a href="https://capgo.app/"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-updater" alt="Capgo - Instant updates for Capacitor" /></a>
3
3
  [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/invite/VnYRvBfgA6)
4
4
  <a href="https://discord.com/invite/VnYRvBfgA6"><img src="https://img.shields.io/discord/912707985829163099?color=%237289DA&label=Discord" alt="Discord">
5
5
  [![npm](https://img.shields.io/npm/dm/@capgo/capacitor-updater)](https://www.npmjs.com/package/@capgo/capacitor-updater)
@@ -296,7 +296,7 @@ CapacitorUpdater can be configured with these options:
296
296
  | **`resetWhenUpdate`** | <code>boolean</code> | 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. | <code>true</code> | |
297
297
  | **`updateUrl`** | <code>string</code> | Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS. | <code>https://plugin.capgo.app/updates</code> | |
298
298
  | **`channelUrl`** | <code>string</code> | Configure the URL / endpoint for channel operations. Only available for Android and iOS. | <code>https://plugin.capgo.app/channel_self</code> | |
299
- | **`statsUrl`** | <code>string</code> | Configure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting. | <code>https://plugin.capgo.app/stats</code> | |
299
+ | **`statsUrl`** | <code>string</code> | 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, and unclean WebView restarts when available. | <code>https://plugin.capgo.app/stats</code> | |
300
300
  | **`publicKey`** | <code>string</code> | Configure the public key for end to end live update encryption Version 2 Only available for Android and iOS. | <code>undefined</code> | 6.2.0 |
301
301
  | **`version`** | <code>string</code> | 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. | <code>undefined</code> | 4.17.48 |
302
302
  | **`directUpdate`** | <code>boolean \| 'always' \| 'atInstall' \| 'onLaunch'</code> | Configure when the plugin should direct install updates. Only for autoUpdate mode. Works well for apps less than 10MB and with uploads done using --delta flag. Zip or apps more than 10MB will be relatively slow for users to update. - false: Never do direct updates (use default behavior: download at start, set when backgrounded) - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false - true: (deprecated) Same as "always" for backward compatibility Activate this flag will automatically make the CLI upload delta in CICD envs and will ask for confirmation in local uploads. Only available for Android and iOS. | <code>false</code> | 5.1.0 |
@@ -449,6 +449,7 @@ export default config;
449
449
  * [`reload()`](#reload)
450
450
  * [`setMultiDelay(...)`](#setmultidelay)
451
451
  * [`cancelDelay()`](#canceldelay)
452
+ * [`triggerUpdateCheck()`](#triggerupdatecheck)
452
453
  * [`getLatest(...)`](#getlatest)
453
454
  * [`setChannel(...)`](#setchannel)
454
455
  * [`unsetChannel(...)`](#unsetchannel)
@@ -462,6 +463,7 @@ export default config;
462
463
  * [`removeAllListeners()`](#removealllisteners)
463
464
  * [`addListener('download', ...)`](#addlistenerdownload-)
464
465
  * [`addListener('noNeedUpdate', ...)`](#addlistenernoneedupdate-)
466
+ * [`addListener('updateCheckResult', ...)`](#addlistenerupdatecheckresult-)
465
467
  * [`addListener('updateAvailable', ...)`](#addlistenerupdateavailable-)
466
468
  * [`addListener('downloadComplete', ...)`](#addlistenerdownloadcomplete-)
467
469
  * [`addListener('breakingAvailable', ...)`](#addlistenerbreakingavailable-)
@@ -906,6 +908,33 @@ This is useful when:
906
908
  --------------------
907
909
 
908
910
 
911
+ #### triggerUpdateCheck()
912
+
913
+ ```typescript
914
+ triggerUpdateCheck() => Promise<TriggerUpdateCheckResult>
915
+ ```
916
+
917
+ Trigger the native auto-update check/download pipeline immediately.
918
+
919
+ This starts the same background update flow used when the app moves to the
920
+ foreground with auto-update enabled. It is useful for native integrations
921
+ such as a silent push notification asking the app to check for a Capgo
922
+ bundle without reimplementing the update protocol in JavaScript.
923
+
924
+ The promise resolves after the native background work has been queued, not
925
+ after the update has been downloaded or installed. Listen to updater events
926
+ such as `updateAvailable`, `downloadComplete`, `downloadFailed`, and
927
+ `noNeedUpdate` for the final result.
928
+
929
+ Native support is available on iOS and Android. On Web, this method returns
930
+ a result with `status: 'unavailable'`. Native platforms also return
931
+ `unavailable` when the native auto-update system is disabled.
932
+
933
+ **Returns:** <code>Promise&lt;<a href="#triggerupdatecheckresult">TriggerUpdateCheckResult</a>&gt;</code>
934
+
935
+ --------------------
936
+
937
+
909
938
  #### getLatest(...)
910
939
 
911
940
  ```typescript
@@ -929,27 +958,23 @@ After receiving the latest version info, you can:
929
958
  2. Download it using {@link download}
930
959
  3. Apply it using {@link next} or {@link set}
931
960
 
932
- **Important: Error handling for "no new version available"**
961
+ **Important: Handling "no new version available"**
933
962
 
934
963
  When the device's current version matches the latest version on the server (i.e., the device is already
935
964
  up-to-date), the server returns a 200 response with `error: "no_new_version_available"` and
936
- `message: "No new version available"`. **This causes `getLatest()` to throw an error**, even though
937
- this is a normal, expected condition.
965
+ `message: "No new version available"`. This is a normal, expected condition and resolves with
966
+ `kind: "up_to_date"` when the backend provides that classification.
938
967
 
939
- You should catch this specific error to handle it gracefully:
968
+ You should check `kind` and `error` before attempting to download:
940
969
 
941
970
  ```typescript
942
- try {
943
- const latest = await CapacitorUpdater.getLatest();
971
+ const latest = await CapacitorUpdater.getLatest();
972
+ if (latest.kind === 'up_to_date') {
973
+ console.log('Already up to date');
974
+ } else if (latest.kind === 'blocked') {
975
+ console.log('Update is blocked:', latest.error);
976
+ } else if (latest.url) {
944
977
  // New version is available, proceed with download
945
- } catch (error) {
946
- if (error.message === 'No new version available') {
947
- // Device is already on the latest version - this is normal
948
- console.log('Already up to date');
949
- } else {
950
- // Actual error occurred
951
- console.error('Failed to check for updates:', error);
952
- }
953
978
  }
954
979
  ```
955
980
 
@@ -1251,6 +1276,7 @@ Remove all event listeners registered for this plugin.
1251
1276
  This unregisters all listeners added via {@link addListener} for all event types:
1252
1277
  - `download`
1253
1278
  - `noNeedUpdate`
1279
+ - `updateCheckResult`
1254
1280
  - `updateAvailable`
1255
1281
  - `downloadComplete`
1256
1282
  - `downloadFailed`
@@ -1308,6 +1334,31 @@ Listen for no need to update event, useful when you want force check every time
1308
1334
  --------------------
1309
1335
 
1310
1336
 
1337
+ #### addListener('updateCheckResult', ...)
1338
+
1339
+ ```typescript
1340
+ addListener(eventName: 'updateCheckResult', listenerFunc: (state: UpdateCheckResultEvent) => void) => Promise<PluginListenerHandle>
1341
+ ```
1342
+
1343
+ Listen for update check results before the updater decides whether to download.
1344
+ The backend can classify the <a href="#updatecheckresultevent">UpdateCheckResultEvent</a> payload as `up_to_date`, `blocked`, or `failed`.
1345
+
1346
+ This event is emitted alongside legacy events. For `up_to_date` and `blocked`, it is emitted before
1347
+ `noNeedUpdate` and does not emit `downloadFailed`. For `failed`, it is emitted before the legacy
1348
+ `downloadFailed` event and keeps the existing failure stats behavior.
1349
+
1350
+ | Param | Type |
1351
+ | ------------------ | --------------------------------------------------------------------------------------------- |
1352
+ | **`eventName`** | <code>'updateCheckResult'</code> |
1353
+ | **`listenerFunc`** | <code>(state: <a href="#updatecheckresultevent">UpdateCheckResultEvent</a>) =&gt; void</code> |
1354
+
1355
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
1356
+
1357
+ **Since:** 8.45.11
1358
+
1359
+ --------------------
1360
+
1361
+
1311
1362
  #### addListener('updateAvailable', ...)
1312
1363
 
1313
1364
  ```typescript
@@ -2092,22 +2143,34 @@ If you don't use backend, you need to provide the URL and version of the bundle.
2092
2143
  | **`value`** | <code>string</code> | |
2093
2144
 
2094
2145
 
2146
+ ##### TriggerUpdateCheckResult
2147
+
2148
+ Result returned after requesting an immediate native auto-update check.
2149
+
2150
+ | Prop | Type | Description |
2151
+ | ------------ | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2152
+ | **`status`** | <code>'queued' \| 'already_running' \| 'unavailable'</code> | Native trigger state: `queued` when a check was queued, `already_running` when the native update pipeline is already active, or `unavailable` on Web or when native auto-update is disabled. |
2153
+ | **`queued`** | <code>boolean</code> | Whether a new native update check was queued. This is `true` only when `status` is `queued`; otherwise it is `false`. |
2154
+
2155
+
2095
2156
  ##### LatestVersion
2096
2157
 
2097
- | Prop | Type | Description | Since |
2098
- | ---------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
2099
- | **`version`** | <code>string</code> | Result of getLatest method | 4.0.0 |
2100
- | **`checksum`** | <code>string</code> | | 6 |
2101
- | **`breaking`** | <code>boolean</code> | Indicates whether the update was flagged as breaking by the backend. | 7.22.0 |
2102
- | **`major`** | <code>boolean</code> | | |
2103
- | **`message`** | <code>string</code> | Optional message from the server. When no new version is available, this will be "No new version available". | |
2104
- | **`sessionKey`** | <code>string</code> | | |
2105
- | **`error`** | <code>string</code> | Error code from the server, if any. Common values: - `"no_new_version_available"`: Device is already on the latest version (not a failure) - Other error codes indicate actual failures in the update process | |
2106
- | **`old`** | <code>string</code> | The previous/current version name (provided for reference). | |
2107
- | **`url`** | <code>string</code> | Download URL for the bundle (when a new version is available). | |
2108
- | **`manifest`** | <code>ManifestEntry[]</code> | File list for delta updates (when using multi-file downloads). | 6.1 |
2109
- | **`link`** | <code>string</code> | Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release). | 7.35.0 |
2110
- | **`comment`** | <code>string</code> | Optional comment or description for this bundle version. | 7.35.0 |
2158
+ | Prop | Type | Description | Since |
2159
+ | ---------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------- |
2160
+ | **`version`** | <code>string</code> | Result of getLatest method | 4.0.0 |
2161
+ | **`checksum`** | <code>string</code> | | 6 |
2162
+ | **`breaking`** | <code>boolean</code> | Indicates whether the update was flagged as breaking by the backend. | 7.22.0 |
2163
+ | **`major`** | <code>boolean</code> | | |
2164
+ | **`message`** | <code>string</code> | Optional message from the server. When no new version is available, this will be "No new version available". | |
2165
+ | **`sessionKey`** | <code>string</code> | | |
2166
+ | **`error`** | <code>string</code> | Error code from the server, if any. Use `kind` for classification instead of parsing this value. | |
2167
+ | **`kind`** | <code><a href="#updateresponsekind">UpdateResponseKind</a></code> | Classification for this response, provided by the backend. | 8.45.11 |
2168
+ | **`statusCode`** | <code>number</code> | HTTP status code returned by the update server for classified update-check responses. | 8.45.11 |
2169
+ | **`old`** | <code>string</code> | The previous/current version name (provided for reference). | |
2170
+ | **`url`** | <code>string</code> | Download URL for the bundle (when a new version is available). | |
2171
+ | **`manifest`** | <code>ManifestEntry[]</code> | File list for delta updates (when using multi-file downloads). | 6.1 |
2172
+ | **`link`** | <code>string</code> | Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release). | 7.35.0 |
2173
+ | **`comment`** | <code>string</code> | Optional comment or description for this bundle version. | 7.35.0 |
2111
2174
 
2112
2175
 
2113
2176
  ##### GetLatestOptions
@@ -2226,6 +2289,18 @@ If you don't use backend, you need to provide the URL and version of the bundle.
2226
2289
  | **`bundle`** | <code><a href="#bundleinfo">BundleInfo</a></code> | Current status of download, between 0 and 100. | 4.0.0 |
2227
2290
 
2228
2291
 
2292
+ ##### UpdateCheckResultEvent
2293
+
2294
+ | Prop | Type | Description | Since |
2295
+ | ---------------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------- |
2296
+ | **`kind`** | <code><a href="#updateresponsekind">UpdateResponseKind</a></code> | Classification for the update check result, provided by the backend. | 8.45.11 |
2297
+ | **`error`** | <code>string</code> | Backend error code, when provided. | 8.45.11 |
2298
+ | **`message`** | <code>string</code> | Backend message, when provided. | 8.45.11 |
2299
+ | **`statusCode`** | <code>number</code> | HTTP status code returned by the update endpoint. | 8.45.11 |
2300
+ | **`version`** | <code>string</code> | Version referenced by the update check result. | 8.45.11 |
2301
+ | **`bundle`** | <code><a href="#bundleinfo">BundleInfo</a></code> | Current bundle on the device. | 8.45.11 |
2302
+
2303
+
2229
2304
  ##### UpdateAvailableEvent
2230
2305
 
2231
2306
  | Prop | Type | Description | Since |
@@ -2417,6 +2492,15 @@ error: The bundle has failed to download.
2417
2492
  <code>'background' | 'kill' | 'nativeVersion' | 'date'</code>
2418
2493
 
2419
2494
 
2495
+ ##### UpdateResponseKind
2496
+
2497
+ Classification for update-check responses that do not provide a downloadable bundle.
2498
+ The update backend provides this field directly. Missing or unknown values are treated as
2499
+ failed by native clients.
2500
+
2501
+ <code>'up_to_date' | 'blocked' | 'failed'</code>
2502
+
2503
+
2420
2504
  ##### BreakingAvailableEvent
2421
2505
 
2422
2506
  Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvailable`.