@capgo/capacitor-updater 9.0.0 → 9.0.2

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.
Files changed (109) hide show
  1. package/CapgoCapacitorUpdater.podspec +3 -6
  2. package/Package.swift +30 -0
  3. package/README.md +2406 -291
  4. package/android/build.gradle +37 -17
  5. package/android/consumer-rules.pro +48 -0
  6. package/android/proguard-rules.pro +23 -0
  7. package/android/src/main/AndroidManifest.xml +0 -1
  8. package/android/src/main/java/ee/forgr/capacitor_updater/AndroidAppExitReporter.java +92 -0
  9. package/android/src/main/java/ee/forgr/capacitor_updater/AppLifecycleObserver.java +115 -0
  10. package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +227 -195
  11. package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +24 -23
  12. package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +13 -0
  13. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +7927 -1243
  14. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +5785 -0
  15. package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +564 -121
  16. package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +44 -0
  17. package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +43 -49
  18. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
  19. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +427 -0
  20. package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +230 -0
  21. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +2041 -118
  22. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +301 -0
  23. package/android/src/main/java/ee/forgr/capacitor_updater/HeadlessUpdateWorker.java +569 -0
  24. package/android/src/main/java/ee/forgr/capacitor_updater/Http3.java +436 -0
  25. package/android/src/main/java/ee/forgr/capacitor_updater/HttpEngineTransport.java +604 -0
  26. package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +79 -0
  27. package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +419 -0
  28. package/android/src/main/java/ee/forgr/capacitor_updater/NativeUpdatePrompt.java +303 -0
  29. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
  30. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +963 -0
  31. package/android/src/main/java/ee/forgr/capacitor_updater/StatsBatchFailureDiagnostics.java +40 -0
  32. package/android/src/main/java/ee/forgr/capacitor_updater/ThreeFingerPinchDetector.java +323 -0
  33. package/android/src/main/java/ee/forgr/capacitor_updater/Version.java +306 -0
  34. package/dist/docs.json +4431 -840
  35. package/dist/esm/definitions.d.ts +2641 -225
  36. package/dist/esm/definitions.js +103 -1
  37. package/dist/esm/definitions.js.map +1 -1
  38. package/dist/esm/history.d.ts +1 -0
  39. package/dist/esm/history.js +283 -0
  40. package/dist/esm/history.js.map +1 -0
  41. package/dist/esm/index.d.ts +3 -2
  42. package/dist/esm/index.js +5 -4
  43. package/dist/esm/index.js.map +1 -1
  44. package/dist/esm/web.d.ts +53 -42
  45. package/dist/esm/web.js +180 -37
  46. package/dist/esm/web.js.map +1 -1
  47. package/dist/plugin.cjs.js +570 -37
  48. package/dist/plugin.cjs.js.map +1 -1
  49. package/dist/plugin.js +570 -37
  50. package/dist/plugin.js.map +1 -1
  51. package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +262 -0
  52. package/ios/Sources/CapacitorUpdaterPlugin/AppHealthTracker.swift +82 -0
  53. package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +185 -0
  54. package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +127 -0
  55. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +6813 -0
  56. package/ios/Sources/CapacitorUpdaterPlugin/CapgoRawRsa.swift +36 -0
  57. package/ios/Sources/CapacitorUpdaterPlugin/CapgoSemanticVersion.swift +200 -0
  58. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +5099 -0
  59. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +387 -0
  60. package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +343 -0
  61. package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
  62. package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +452 -0
  63. package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +380 -0
  64. package/ios/Sources/CapacitorUpdaterPlugin/NativeUpdatePrompt.swift +183 -0
  65. package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +96 -0
  66. package/ios/Sources/CapacitorUpdaterPlugin/RedirectPolicyDelegate.swift +97 -0
  67. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +876 -0
  68. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
  69. package/ios/Sources/CapacitorUpdaterPlugin/WKWebView+CapgoObjcBridge.swift +20 -0
  70. package/ios/Sources/CapacitorUpdaterPlugin/WebViewStatsReporter.swift +304 -0
  71. package/ios/Sources/CapacitorUpdaterPlugin/ZipArchiveReader.swift +247 -0
  72. package/ios/Sources/CapacitorUpdaterPlugin/ZipCentralDirectory.swift +280 -0
  73. package/ios/Tests/CapacitorUpdaterPluginTests/BuiltinHashesTests.swift +210 -0
  74. package/ios/Tests/CapacitorUpdaterPluginTests/BundleHardeningTests.swift +292 -0
  75. package/ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift +6533 -0
  76. package/ios/Tests/CapacitorUpdaterPluginTests/CapgoSemanticVersionTests.swift +64 -0
  77. package/ios/Tests/CapacitorUpdaterPluginTests/ChecksumRequiredTests.swift +156 -0
  78. package/ios/Tests/CapacitorUpdaterPluginTests/CliCryptoFixtureTests.swift +314 -0
  79. package/ios/Tests/CapacitorUpdaterPluginTests/HttpsOnlyBuiltinMinimumTests.swift +653 -0
  80. package/ios/Tests/CapacitorUpdaterPluginTests/InstallPerfTests.swift +174 -0
  81. package/ios/Tests/CapacitorUpdaterPluginTests/ListChannelsTests.swift +74 -0
  82. package/ios/Tests/CapacitorUpdaterPluginTests/LoggerSecurityTests.swift +149 -0
  83. package/ios/Tests/CapacitorUpdaterPluginTests/NativeContractTests.swift +160 -0
  84. package/ios/Tests/CapacitorUpdaterPluginTests/NetworkTransportTests.swift +1109 -0
  85. package/ios/Tests/CapacitorUpdaterPluginTests/PopulateDeltaCacheTests.swift +573 -0
  86. package/ios/Tests/CapacitorUpdaterPluginTests/RedirectPolicyTests.swift +63 -0
  87. package/ios/Tests/CapacitorUpdaterPluginTests/RsaContractTests.swift +281 -0
  88. package/ios/Tests/CapacitorUpdaterPluginTests/SessionKeyRequiredTests.swift +196 -0
  89. package/ios/Tests/CapacitorUpdaterPluginTests/TestZipWriter.swift +235 -0
  90. package/ios/Tests/CapacitorUpdaterPluginTests/UpdateLifecycleTests.swift +470 -0
  91. package/ios/Tests/CapacitorUpdaterPluginTests/WebKitOverlayGuardTests.swift +32 -0
  92. package/ios/Tests/CapacitorUpdaterPluginTests/ZipArchiveReaderTests.swift +302 -0
  93. package/ios/Tests/CapacitorUpdaterPluginTests/ZipBundleExtractionTests.swift +122 -0
  94. package/package.json +80 -43
  95. package/scripts/builtin-hashes-lib.mjs +148 -0
  96. package/scripts/capacitor-builtin-hashes-hook.mjs +65 -0
  97. package/scripts/resolve-real-path.mjs +25 -0
  98. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +0 -1130
  99. package/ios/Plugin/BundleInfo.swift +0 -113
  100. package/ios/Plugin/BundleStatus.swift +0 -48
  101. package/ios/Plugin/CapacitorUpdater.swift +0 -858
  102. package/ios/Plugin/CapacitorUpdaterPlugin.h +0 -10
  103. package/ios/Plugin/CapacitorUpdaterPlugin.m +0 -27
  104. package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -677
  105. package/ios/Plugin/CryptoCipher.swift +0 -240
  106. /package/{LICENCE → LICENSE} +0 -0
  107. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
  108. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
  109. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
@@ -1,8 +1,8 @@
1
- import type { PluginListenerHandle } from "@capacitor/core";
2
- declare module "@capacitor/cli" {
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ declare module '@capacitor/cli' {
3
3
  interface PluginsConfig {
4
4
  /**
5
- * These configuration values are available:
5
+ * CapacitorUpdater can be configured with these options:
6
6
  */
7
7
  CapacitorUpdater?: {
8
8
  /**
@@ -11,9 +11,21 @@ declare module "@capacitor/cli" {
11
11
  * Only available for Android and iOS.
12
12
  *
13
13
  * @default 10000 // (10 seconds)
14
- * @example 1000 // (1 second)
14
+ * @example 1000 // (1 second, minimum 1000)
15
15
  */
16
16
  appReadyTimeout?: number;
17
+ /**
18
+ * Configure the number of seconds the native plugin should wait before considering an HTTP timeout.
19
+ * Applies to update checks and file downloads. On Android these are idle connect/read/write
20
+ * timeouts and do not cap total download time; on iOS the request timeout also bounds the
21
+ * total download duration.
22
+ *
23
+ * Only available for Android and iOS.
24
+ *
25
+ * @default 20 // (20 second)
26
+ * @example 10 // (10 second)
27
+ */
28
+ responseTimeout?: number;
17
29
  /**
18
30
  * Configure whether the plugin should use automatically delete failed bundles.
19
31
  *
@@ -33,17 +45,38 @@ declare module "@capacitor/cli" {
33
45
  */
34
46
  autoDeletePrevious?: boolean;
35
47
  /**
36
- * Configure whether the plugin should use Auto Update via an update server.
48
+ * Configure how the plugin checks for, downloads, and applies live updates.
49
+ *
50
+ * The plugin checks for updates when the app moves to the foreground. When
51
+ * {@link periodCheckDelay} is greater than 0, it also checks on a repeating timer
52
+ * while the app stays open.
53
+ *
54
+ * Boolean values keep their existing behavior:
55
+ * - `true`: Same as `"atBackground"`.
56
+ * - `false`: Same as `"off"`.
57
+ *
58
+ * String values merge the previous Auto Update and Direct Update configuration:
59
+ * - `"off"`: Disable automatic update checks.
60
+ * - `"atBackground"`: Check and download automatically on each foreground check, then apply the update the next time the app moves to background.
61
+ * - `"atInstall"`: Apply immediately only after a fresh install or native app store update; otherwise use `"atBackground"` behavior.
62
+ * - `"onLaunch"`: Apply immediately only when the app is brought to the foreground from a killed state (cold start). After that first check, fall back to `"atBackground"` behavior.
63
+ * - `"always"`: Check on every foreground transition and apply immediately whenever an update is available.
64
+ * - `"onlyDownload"`: Check and download automatically, emit `updateAvailable`, and never set the next bundle or apply an update automatically.
65
+ *
66
+ * Instant apply modes (`"atInstall"`, `"onLaunch"`, `"always"`) apply while the user is waiting.
67
+ * Upload with `npx @capgo/cli@latest bundle upload --delta` so only changed files download. A full zip upload slows the user experience.
68
+ * They apply without `autoSplashscreen`, but `autoSplashscreen: true` (with `@capacitor/splash-screen` installed and
69
+ * `launchAutoHide: false`) is recommended so the splash screen covers the wait and hides itself afterwards.
37
70
  *
38
71
  * Only available for Android and iOS.
39
72
  *
40
73
  * @default true
41
- * @example false
74
+ * @example "onlyDownload"
42
75
  */
43
- autoUpdate?: boolean;
76
+ autoUpdate?: boolean | 'off' | 'atBackground' | 'atInstall' | 'onLaunch' | 'always' | 'onlyDownload';
44
77
  /**
45
78
  * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.
46
- *
79
+ * 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.
47
80
  * Only available for Android and iOS.
48
81
  *
49
82
  * @default true
@@ -55,27 +88,54 @@ declare module "@capacitor/cli" {
55
88
  *
56
89
  * Only available for Android and iOS.
57
90
  *
58
- * @default https://api.capgo.app/auto_update
91
+ * @default https://plugin.capgo.app/updates
59
92
  * @example https://example.com/api/auto_update
60
93
  */
61
94
  updateUrl?: string;
95
+ /**
96
+ * Configure the URL / endpoint for channel operations.
97
+ *
98
+ * Only available for Android and iOS.
99
+ *
100
+ * @default https://plugin.capgo.app/channel_self
101
+ * @example https://example.com/api/channel
102
+ */
103
+ channelUrl?: string;
62
104
  /**
63
105
  * Configure the URL / endpoint to which update statistics are sent.
64
106
  *
65
107
  * Only available for Android and iOS. Set to "" to disable stats reporting.
108
+ * Native stats include update lifecycle events, app health signals such as crashes,
109
+ * Android ANRs, low-memory exits, iOS memory warnings, and WebView health signals
110
+ * such as JavaScript errors, unhandled promise rejections, resource load failures,
111
+ * WebView renderer exits, unclean WebView restarts, app launch readiness timing,
112
+ * and WebView load milestones when available.
66
113
  *
67
- * @default https://api.capgo.app/stats
114
+ * Failed background update checks that never start a download (network errors, timeouts,
115
+ * non-2xx responses, unreadable payloads) are reported as `update_check_error` with
116
+ * `metadata.error` and optional `metadata.status_code`, not as `download_fail`.
117
+ * Self-hosted Capgo backends must allow the `update_check_error` stats action.
118
+ *
119
+ * @default https://plugin.capgo.app/stats
68
120
  * @example https://example.com/api/stats
69
121
  */
70
122
  statsUrl?: string;
71
123
  /**
72
- * Configure the private key for end to end live update encryption.
124
+ * Configure the public key for end to end live update encryption Version 2.
125
+ *
126
+ * What it guarantees: a bundle can only be installed when its checksum and session key were produced with
127
+ * the matching private key. Capgo never holds that key, so Capgo cannot create, modify or decrypt an update
128
+ * for your app. It does NOT make the bundle unreadable to someone who has your app binary: the public key
129
+ * ships inside the app, and anyone holding the app can recover the session key and read the bundle. If you
130
+ * also need Capgo to be unable to find your app (and so its public key), use a Capgo app id that is not your
131
+ * store bundle id (`appId` in this plugin config) so the app is not identifiable from the dashboard.
73
132
  *
74
133
  * Only available for Android and iOS.
75
134
  *
76
135
  * @default undefined
136
+ * @since 6.2.0
77
137
  */
78
- privateKey?: string;
138
+ publicKey?: string;
79
139
  /**
80
140
  * Configure the current version of the app. This will be used for the first update request.
81
141
  * If not set, the plugin will get the version from the native code.
@@ -86,101 +146,2047 @@ declare module "@capacitor/cli" {
86
146
  * @since 4.17.48
87
147
  */
88
148
  version?: string;
149
+ /**
150
+ * Let the plugin handle the splashscreen: keep it up while an instant apply update runs, then hide it when the
151
+ * update finishes, when no update is needed, or after {@link autoSplashscreenTimeout}. It controls splash handling
152
+ * only, not whether an update applies immediately (that is {@link autoUpdate}); it is recommended with the instant
153
+ * apply modes (`"atInstall"`, `"onLaunch"`, `"always"`) so users do not see the app reload.
154
+ * `@capacitor/splash-screen` must be installed and configured with `launchAutoHide: false`.
155
+ * This removes the need to manually listen for appReady events and call SplashScreen.hide().
156
+ *
157
+ * Only available for Android and iOS.
158
+ *
159
+ * @default false
160
+ * @since 7.6.0
161
+ */
162
+ autoSplashscreen?: boolean;
163
+ /**
164
+ * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.
165
+ * Only takes effect when {@link autoSplashscreen} is enabled.
166
+ * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
167
+ *
168
+ * Only available for Android and iOS.
169
+ *
170
+ * @default false
171
+ * @since 7.19.0
172
+ */
173
+ autoSplashscreenLoader?: boolean;
174
+ /**
175
+ * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.
176
+ * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.
177
+ * Set to `0` (zero) to disable the timeout.
178
+ * If installation has not started when the timeout fires, the downloaded bundle is installed on the next background/launch.
179
+ * If installation has already started, the splashscreen still hides at the deadline while the reload and app-ready checks finish.
180
+ * This can briefly expose the previous page while the new bundle loads.
181
+ * Requires {@link autoSplashscreen} to be enabled.
182
+ *
183
+ * Only available for Android and iOS.
184
+ *
185
+ * @default 10000 // (10 seconds)
186
+ * @since 7.19.0
187
+ */
188
+ autoSplashscreenTimeout?: number;
189
+ /**
190
+ * Configure the interval in seconds for repeating update checks while the app stays open.
191
+ * Foreground checks still run when this is 0. Values below 600 are normalized to 600.
192
+ *
193
+ * Only available for Android and iOS.
194
+ * Cannot be less than 600 seconds (10 minutes).
195
+ *
196
+ * @default 0 (disabled)
197
+ * @example 3600 (1 hour)
198
+ * @example 86400 (24 hours)
199
+ */
200
+ periodCheckDelay?: number;
201
+ /**
202
+ * Configure the CLI to use a local server for testing or self-hosted update server.
203
+ *
204
+ *
205
+ * @default undefined
206
+ * @since 4.17.48
207
+ */
208
+ localS3?: boolean;
209
+ /**
210
+ * Configure the CLI to use a local server for testing or self-hosted update server.
211
+ *
212
+ *
213
+ * @default undefined
214
+ * @since 4.17.48
215
+ */
216
+ localHost?: string;
217
+ /**
218
+ * Configure the CLI to use a local server for testing or self-hosted update server.
219
+ *
220
+ *
221
+ * @default undefined
222
+ * @since 4.17.48
223
+ */
224
+ localWebHost?: string;
225
+ /**
226
+ * Configure the CLI to use a local server for testing or self-hosted update server.
227
+ *
228
+ *
229
+ * @default undefined
230
+ * @since 4.17.48
231
+ */
232
+ localSupa?: string;
233
+ /**
234
+ * Configure the CLI to use a local server for testing.
235
+ *
236
+ *
237
+ * @default undefined
238
+ * @since 4.17.48
239
+ */
240
+ localSupaAnon?: string;
241
+ /**
242
+ * Configure the CLI to use a local api for testing.
243
+ *
244
+ *
245
+ * @default undefined
246
+ * @since 6.3.3
247
+ */
248
+ localApi?: string;
249
+ /**
250
+ * Configure the CLI to use a local file api for testing.
251
+ *
252
+ *
253
+ * @default undefined
254
+ * @since 6.3.3
255
+ */
256
+ localApiFiles?: string;
257
+ /**
258
+ * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.
259
+ *
260
+ *
261
+ * @default false
262
+ * @since 5.4.0
263
+ */
264
+ allowModifyUrl?: boolean;
265
+ /**
266
+ * Allow the plugin to follow redirects from HTTPS to plain HTTP for its own network requests
267
+ * (update checks, stats, channel calls, and bundle/manifest downloads).
268
+ *
269
+ * Blocked by default so a redirect can never downgrade updater traffic to an unencrypted connection.
270
+ * Only enable this if your self-hosted update server or CDN must redirect to an HTTP URL.
271
+ * `httpsOnly` (default `true`) rejects every non-https URL and redirect hop regardless of this setting, so an
272
+ * HTTP redirect also needs `httpsOnly: false`. Direct HTTP URLs (for example `localApi` during development) are
273
+ * only allowed with `httpsOnly: false` as well.
274
+ *
275
+ * Only available for Android and iOS.
276
+ *
277
+ * @default false
278
+ * @since 8.52.0
279
+ */
280
+ allowHttpsToHttpRedirect?: boolean;
281
+ /**
282
+ * Require https for every URL the plugin talks to: `updateUrl`, `statsUrl`, `channelUrl` (from config,
283
+ * persisted values and `setUpdateUrl` / `setStatsUrl` / `setChannelUrl`), bundle zip URLs, every manifest
284
+ * `download_url`, preview payload URLs and every redirect hop. When enabled it overrides
285
+ * `allowHttpsToHttpRedirect`. A non-https URL fails the call or download with
286
+ * `httpsOnly is enabled and <url> is not https`.
287
+ *
288
+ * Set to `false` only for local development servers (for example a plain-http `localApi` on loopback) or a
289
+ * self-hosted plain-http update server you control. Upgrading with a plain-http `updateUrl`, `statsUrl`,
290
+ * `channelUrl` or `allowHttpsToHttpRedirect: true` requires setting this to `false` explicitly.
291
+ *
292
+ * Only available for Android and iOS.
293
+ *
294
+ * @default true
295
+ * @since 8.54.0
296
+ */
297
+ httpsOnly?: boolean;
298
+ /**
299
+ * Let bundle and manifest downloads use HTTP/3 when the server advertises it.
300
+ *
301
+ * Android 14+ (and Android 12 or 13 with the S extension at level 7) sends https downloads through the
302
+ * platform `HttpEngine`, which keeps the server's HTTP/3 support across app launches and falls back to
303
+ * HTTP/2 (or HTTP/1.1 when the server lacks HTTP/2) on its own when QUIC is blocked. Older Android versions
304
+ * keep the current OkHttp client (HTTP/2 or HTTP/1.1). iOS marks download requests as HTTP/3 capable, and
305
+ * URLSession falls back to HTTP/2 or HTTP/1.1 when QUIC fails or the server does not support HTTP/3.
306
+ * Update checks, stats and channel calls are not affected.
307
+ *
308
+ * Set to `false` to stop preferring HTTP/3. Android then keeps downloads on the previous OkHttp client
309
+ * (HTTP/2 or HTTP/1.1). iOS no longer marks downloads as HTTP/3 capable, but URLSession can still pick
310
+ * HTTP/3 on its own if it already learned the server supports it, so `false` is not a hard HTTP/2 guarantee there.
311
+ *
312
+ * Only available for Android and iOS.
313
+ *
314
+ * @default true
315
+ * @since 8.55.0
316
+ */
317
+ http3?: boolean;
318
+ /**
319
+ * Refuse to download or install a bundle whose version is lower than the native app version
320
+ * (`version` config override, else `CFBundleShortVersionString` / `versionName`). This is the on-device
321
+ * counterpart of the Capgo channel setting "disable auto update under native" and protects against a
322
+ * replayed old update response rolling the app back below its store version. This is not strict semver
323
+ * validation: both versions are read as a numeric core, ignoring whitespace and `+build` metadata, cutting the
324
+ * prerelease at the first `-`, and taking the leading digits of the first three dot-separated parts (missing or
325
+ * non-numeric parts count as `0`, extra parts are ignored). So a `1.2.3-beta.1` bundle is accepted on native
326
+ * `1.2.3`, `1.2.preview` is read as `1.2.0`, and native `2.0.0.4` compares as `2.0.0`. Only a version that does
327
+ * not start with a digit (after whitespace is removed) skips the check. Rejections are reported as the
328
+ * `version_below_native` stat. Set it to `false` if you version web bundles independently of the native
329
+ * app (for example native `2.0.0` with bundle `1.4.7`). The default was `false` before 9.0.0.
330
+ *
331
+ * Only available for Android and iOS.
332
+ *
333
+ * @default true
334
+ * @since 8.54.0
335
+ */
336
+ builtinMinimum?: boolean;
337
+ /**
338
+ * Allow the plugin to modify the appId dynamically from the JavaScript side.
339
+ *
340
+ *
341
+ * @default false
342
+ * @since 7.14.0
343
+ */
344
+ allowModifyAppId?: boolean;
345
+ /**
346
+ * Allow marking bundles as errored from JavaScript while using manual update flows.
347
+ * When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`.
348
+ *
349
+ * @default false
350
+ * @since 7.20.0
351
+ */
352
+ allowManualBundleError?: boolean;
353
+ /**
354
+ * Allow JavaScript to start a native preview session and temporarily request updates for another app id.
355
+ * This is intended for trusted container apps that implement Expo Go-style preview flows.
356
+ *
357
+ * Only available for Android and iOS.
358
+ *
359
+ * @default false
360
+ * @since 8.47.0
361
+ */
362
+ allowPreview?: boolean;
363
+ /**
364
+ * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.
365
+ * Set it to `false` to keep the customId in memory only, so it resets on every app launch.
366
+ * Calling `setCustomId({ customId: '' })` clears the saved value even when persistence is disabled.
367
+ * The default was `false` before 9.0.0.
368
+ *
369
+ * Only available for Android and iOS.
370
+ *
371
+ * @default true
372
+ * @since 7.17.3
373
+ */
374
+ persistCustomId?: boolean;
375
+ /**
376
+ * Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl},
377
+ * {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts.
378
+ *
379
+ * Only available for Android and iOS.
380
+ *
381
+ * @default false
382
+ * @since 7.20.0
383
+ */
384
+ persistModifyUrl?: boolean;
385
+ /**
386
+ * Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel.
387
+ * When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.
388
+ *
389
+ * @default true
390
+ * @since 7.34.0
391
+ */
392
+ allowSetDefaultChannel?: boolean;
393
+ /**
394
+ * Keep the default channel stored by {@link CapacitorUpdaterPlugin.setChannel} or refreshed by
395
+ * {@link CapacitorUpdaterPlugin.getChannel} when app data is restored into a new app install.
396
+ *
397
+ * `setChannel()` and a successful `getChannel()` still persist the selected channel across app
398
+ * restarts. When this option is `false`, native startup clears that persisted channel when it
399
+ * detects app data restored into a new installation. Native build cleanup clears the persisted
400
+ * channel only when `persistDefaultChannelOnReinstall` is `false`, `resetWhenUpdate` is `true`,
401
+ * and the native build version has changed.
402
+ *
403
+ * Only available for Android and iOS.
404
+ *
405
+ * @default true
406
+ * @since 8.51.0
407
+ */
408
+ persistDefaultChannelOnReinstall?: boolean;
409
+ /**
410
+ * Set the default channel for the app in the config. Case sensitive.
411
+ * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.
412
+ * This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options
413
+ *
414
+ *
415
+ * @default undefined
416
+ * @since 5.5.0
417
+ */
418
+ defaultChannel?: string;
419
+ /**
420
+ * Configure the app id for the app in the config.
421
+ *
422
+ * @default undefined
423
+ * @since 6.0.0
424
+ */
425
+ appId?: string;
426
+ /**
427
+ * Configure the plugin to keep the URL path after a reload.
428
+ * WARNING: When a reload is triggered, 'window.history' will be cleared.
429
+ *
430
+ * @default false
431
+ * @since 6.8.0
432
+ */
433
+ keepUrlPathAfterReload?: boolean;
434
+ /**
435
+ * Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done
436
+ *
437
+ * @default false
438
+ * @since 7.3.0
439
+ */
440
+ disableJSLogging?: boolean;
441
+ /**
442
+ * Enable OS-level logging. When enabled, logs are written to the system log which can be inspected in production builds.
443
+ *
444
+ * - **iOS**: Uses os_log instead of Swift.print, logs accessible via Console.app or Instruments
445
+ * - **Android**: Logs to Logcat (android.util.Log)
446
+ *
447
+ * When set to false, system logging is disabled on both platforms (only JavaScript console logging will occur if enabled).
448
+ *
449
+ * This is useful for debugging production apps (App Store/TestFlight builds on iOS, or production APKs on Android).
450
+ *
451
+ * @default true
452
+ * @since 8.42.0
453
+ */
454
+ osLogging?: boolean;
455
+ /**
456
+ * Enable the native preview menu gesture while a preview session is active.
457
+ * Outside preview sessions this preview menu is ignored, unless
458
+ * {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector} is enabled.
459
+ *
460
+ * @default false
461
+ * @since 7.5.0
462
+ */
463
+ shakeMenu?: boolean;
464
+ /**
465
+ * Choose which native gesture opens the preview/channel menu.
466
+ * This applies to both {@link PluginsConfig.CapacitorUpdater.shakeMenu}
467
+ * and {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
468
+ *
469
+ * Only available for Android and iOS.
470
+ *
471
+ * @default 'shake'
472
+ * @since 8.48.0
473
+ */
474
+ shakeMenuGesture?: ShakeMenuGesture;
475
+ /**
476
+ * Enable the native menu gesture to show a channel selector menu for switching between update channels.
477
+ * If {@link PluginsConfig.CapacitorUpdater.shakeMenu} is also enabled while a preview session is active,
478
+ * the shake menu includes both preview actions and channel switching.
479
+ * The native gesture can be changed with {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}.
480
+ *
481
+ * Only available for Android and iOS.
482
+ *
483
+ * @default false
484
+ * @since 8.43.0
485
+ */
486
+ allowShakeChannelSelector?: boolean;
487
+ /**
488
+ * When enabled, show a native dialog prompting the user to install a newer native app from the App Store or Play Store.
489
+ * The prompt appears when a live update is blocked because the device native app is too old, including backend
490
+ * `disable_auto_update_*` responses, `store_update_required`, and `breakingAvailable` flows.
491
+ *
492
+ * Only available for Android and iOS. No-op on web.
493
+ *
494
+ * @default false
495
+ * @since 8.53.0
496
+ */
497
+ nativeUpdatePrompt?: boolean;
498
+ /**
499
+ * Optional title for the native store update dialog shown when {@link PluginsConfig.CapacitorUpdater.nativeUpdatePrompt} is enabled.
500
+ *
501
+ * Only available for Android and iOS.
502
+ *
503
+ * @default "Update available"
504
+ * @since 8.53.0
505
+ */
506
+ nativeUpdatePromptTitle?: string;
507
+ /**
508
+ * Optional message body for the native store update dialog shown when {@link PluginsConfig.CapacitorUpdater.nativeUpdatePrompt} is enabled.
509
+ *
510
+ * Only available for Android and iOS.
511
+ *
512
+ * @default A short message explaining that a newer native app is available in the store.
513
+ * @since 8.53.0
514
+ */
515
+ nativeUpdatePromptMessage?: string;
516
+ /**
517
+ * Optional label for the primary action button that opens the store or starts an in-app update on Android.
518
+ *
519
+ * Only available for Android and iOS.
520
+ *
521
+ * @default "Update"
522
+ * @since 8.53.0
523
+ */
524
+ nativeUpdatePromptUpdateButton?: string;
525
+ /**
526
+ * Optional label for the dismiss action on the native store update dialog.
527
+ *
528
+ * Only available for Android and iOS.
529
+ *
530
+ * @default "Not now"
531
+ * @since 8.53.0
532
+ */
533
+ nativeUpdatePromptLaterButton?: string;
534
+ /**
535
+ * Optional ISO 3166-1 alpha-2 country filter. When set, the prompt is shown only when the device region matches
536
+ * one of the comma-separated country codes (for example `"US"` or `"US,CA"`).
537
+ *
538
+ * Only available for Android and iOS.
539
+ *
540
+ * @default undefined (show in all regions)
541
+ * @since 8.53.0
542
+ */
543
+ nativeUpdatePromptCountry?: string;
544
+ /**
545
+ * When {@link PluginsConfig.CapacitorUpdater.nativeUpdatePrompt} is enabled, also show the dialog when {@link CapacitorUpdaterPlugin.getAppUpdateInfo}
546
+ * reports that a store update is available.
547
+ *
548
+ * Only available for Android and iOS.
549
+ *
550
+ * @default false
551
+ * @since 8.53.0
552
+ */
553
+ nativeUpdatePromptOnStoreCheck?: boolean;
554
+ /**
555
+ * Minimum hours between native update prompts for the same native app version. Also limited to once per app session.
556
+ *
557
+ * Only available for Android and iOS.
558
+ *
559
+ * @default 24
560
+ * @since 8.53.0
561
+ */
562
+ nativeUpdatePromptCooldownHours?: number;
89
563
  };
90
564
  }
91
565
  }
92
- export interface noNeedEvent {
566
+ export interface CapacitorUpdaterPlugin {
93
567
  /**
94
- * Current status of download, between 0 and 100.
568
+ * Notify the native layer that JavaScript initialized successfully.
95
569
  *
96
- * @since 4.0.0
570
+ * **CRITICAL: You must call this method on every app launch to prevent automatic rollback.**
571
+ *
572
+ * This is a simple notification to confirm that your bundle's JavaScript loaded and executed.
573
+ * The native web server successfully served the bundle files and your JS runtime started.
574
+ * That's all it checks - nothing more complex.
575
+ *
576
+ * **What triggers rollback:**
577
+ * - NOT calling this method within the timeout (default: 10 seconds)
578
+ * - Complete JavaScript failure (bundle won't load at all)
579
+ *
580
+ * **What does NOT trigger rollback:**
581
+ * - Runtime errors after initialization (API failures, crashes, etc.)
582
+ * - Network request failures
583
+ * - Application logic errors
584
+ *
585
+ * **IMPORTANT: Call this BEFORE any network requests.**
586
+ * Don't wait for APIs, data loading, or async operations. Call it as soon as your
587
+ * JavaScript bundle starts executing to confirm the bundle itself is valid.
588
+ *
589
+ * Best practices:
590
+ * - Call immediately in your app entry point (main.js, app component mount, etc.)
591
+ * - Don't put it after network calls or heavy initialization
592
+ * - Don't wrap it in try/catch with conditions
593
+ * - Adjust {@link PluginsConfig.CapacitorUpdater.appReadyTimeout} if you need more time
594
+ *
595
+ * @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.
97
596
  */
98
- bundle: BundleInfo;
99
- }
100
- export interface updateAvailableEvent {
597
+ notifyAppReady(): Promise<AppReadyResult>;
101
598
  /**
102
- * Current status of download, between 0 and 100.
599
+ * Set the update URL for the app dynamically at runtime.
103
600
  *
104
- * @since 4.0.0
601
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.updateUrl} config value.
602
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
603
+ *
604
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
605
+ * Otherwise, the URL will reset to the config value on next app launch.
606
+ *
607
+ * @param options Contains the URL to use for checking for updates.
608
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
609
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
610
+ * @since 5.4.0
105
611
  */
106
- bundle: BundleInfo;
107
- }
108
- export interface channelRes {
612
+ setUpdateUrl(options: UpdateUrl): Promise<void>;
109
613
  /**
110
- * Current status of set channel
614
+ * Set the statistics URL for the app dynamically at runtime.
111
615
  *
112
- * @since 4.7.0
616
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.statsUrl} config value.
617
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
618
+ *
619
+ * Pass an empty string to disable statistics gathering entirely.
620
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
621
+ *
622
+ * @param options Contains the URL to use for sending statistics, or an empty string to disable.
623
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
624
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
625
+ * @since 5.4.0
113
626
  */
114
- status: string;
115
- error?: any;
116
- message?: any;
117
- }
118
- export interface getChannelRes {
627
+ setStatsUrl(options: StatsUrl): Promise<void>;
628
+ /**
629
+ * Set the channel URL for the app dynamically at runtime.
630
+ *
631
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.channelUrl} config value.
632
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
633
+ *
634
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
635
+ * Otherwise, the URL will reset to the config value on next app launch.
636
+ *
637
+ * @param options Contains the URL to use for channel operations.
638
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
639
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
640
+ * @since 5.4.0
641
+ */
642
+ setChannelUrl(options: ChannelUrl): Promise<void>;
643
+ /**
644
+ * Download a new bundle from the provided URL for later installation.
645
+ *
646
+ * The downloaded bundle is stored locally but not activated. To use it:
647
+ * - Call {@link next} to set it for installation on next app backgrounding/restart
648
+ * - Call {@link set} to activate it immediately (destroys current JavaScript context)
649
+ *
650
+ * The URL should point to a zip file containing either:
651
+ * - Your app files directly in the zip root, or
652
+ * - A single folder containing all your app files
653
+ *
654
+ * The bundle must include an `index.html` file at the root level.
655
+ *
656
+ * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.
657
+ * For multi-file delta updates, provide the `manifest` array.
658
+ *
659
+ * **Android Background Runner note:** `@capacitor/background-runner` loads its
660
+ * configured runner script from native APK assets. Live updates cannot replace
661
+ * that runner script. Keep it stable across OTA updates and ship a native app
662
+ * update when the runner code changes. When a bundle switch happens, Capacitor
663
+ * Updater cancels and reschedules configured Background Runner WorkManager jobs
664
+ * and syncs the bundled runner script into native `public/` storage when present.
665
+ *
666
+ * @example
667
+ * const bundle = await CapacitorUpdater.download({
668
+ * url: `https://example.com/versions/${version}/dist.zip`,
669
+ * version: version
670
+ * });
671
+ * // Bundle is downloaded but not active yet
672
+ * await CapacitorUpdater.next({ id: bundle.id }); // Will activate on next background
673
+ *
674
+ * @param options The {@link DownloadOptions} for downloading a new bundle zip.
675
+ * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the downloaded bundle.
676
+ * @throws {Error} If the download fails or the bundle is invalid.
677
+ */
678
+ download(options: DownloadOptions): Promise<BundleInfo>;
679
+ /**
680
+ * Set the next bundle to be activated when the app backgrounds or restarts.
681
+ *
682
+ * This is the recommended way to apply updates as it doesn't interrupt the user's current session.
683
+ * The bundle will be activated when:
684
+ * - The app is backgrounded (user switches away), or
685
+ * - The app is killed and relaunched, or
686
+ * - {@link reload} is called manually
687
+ *
688
+ * Unlike {@link set}, this method does NOT destroy the current JavaScript context immediately.
689
+ * Your app continues running normally until one of the above events occurs.
690
+ *
691
+ * Use {@link setMultiDelay} to add additional conditions before the update is applied.
692
+ *
693
+ * @param options Contains the ID of the bundle to set as next. Use {@link BundleInfo.id} from a downloaded bundle.
694
+ * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.
695
+ * @throws {Error} When there is no index.html file inside the bundle folder or the bundle doesn't exist.
696
+ */
697
+ next(options: BundleId): Promise<BundleInfo>;
698
+ /**
699
+ * Set the current bundle and immediately reloads the app.
700
+ *
701
+ * **IMPORTANT: This is a terminal operation that destroys the current JavaScript context.**
702
+ *
703
+ * When you call this method:
704
+ * - The entire JavaScript context is immediately destroyed
705
+ * - The app reloads from a different folder with different files
706
+ * - NO code after this call will execute
707
+ * - NO promises will resolve
708
+ * - NO callbacks will fire
709
+ * - Event listeners registered after this call are unreliable and may never fire
710
+ *
711
+ * The reload happens automatically - you don't need to do anything else.
712
+ * If you need to preserve state like the current URL path, use the {@link PluginsConfig.CapacitorUpdater.keepUrlPathAfterReload} config option.
713
+ * For other state preservation needs, save your data before calling this method (e.g., to localStorage).
714
+ *
715
+ * **Do not** try to execute additional logic after calling `set()` - it won't work as expected.
716
+ *
717
+ * @param options A {@link BundleId} object containing the new bundle id to set as current.
718
+ * @returns {Promise<void>} A promise that will never resolve because the JavaScript context is destroyed.
719
+ * @throws {Error} When there is no index.html file inside the bundle folder.
720
+ */
721
+ set(options: BundleId): Promise<void>;
722
+ /**
723
+ * Start a temporary preview/testing session.
724
+ *
725
+ * This stores the currently active bundle as the pending fallback, enables the
726
+ * native shake menu, and makes the next applied bundle show a native notice
727
+ * explaining that shaking the device can reload or leave the preview.
728
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
729
+ * When `appId` is provided, the preview session temporarily uses that app id
730
+ * for update checks until the user leaves the preview. Native updater stats are
731
+ * skipped while the preview session is active.
732
+ *
733
+ * Use this before calling {@link set} for Expo Go-style preview flows.
734
+ * Use {@link listPreviews}, {@link setPreview}, {@link resetPreview},
735
+ * {@link deletePreview}, {@link checkPreviewUpdate}, and
736
+ * {@link updatePreview} to manage saved local previews.
737
+ *
738
+ * @param options Optional preview session options.
739
+ * @returns {Promise<void>} Resolves when preview session state is prepared.
740
+ * @since 8.47.0
741
+ */
742
+ startPreviewSession(options?: StartPreviewSessionOptions): Promise<void>;
743
+ /**
744
+ * Get every locally available preview bundle that was registered by
745
+ * {@link startPreviewSession} and later applied with {@link set}.
746
+ *
747
+ * This only returns previews whose bundles are still available locally. It is
748
+ * safe to show this in a preview switcher or native debug menu.
749
+ *
750
+ * @returns {Promise<PreviewListResult>} Locally available previews and current preview state.
751
+ * @throws {Error} If preview sessions are not enabled by config.
752
+ * @since 8.49.0
753
+ */
754
+ listPreviews(): Promise<PreviewListResult>;
755
+ /**
756
+ * Switch to a locally available preview bundle and reload the WebView.
757
+ *
758
+ * If the app is not already in a preview session, the current live bundle is
759
+ * saved as the fallback so {@link resetPreview} or the native shake menu can
760
+ * return to it later.
761
+ *
762
+ * @param options A {@link BundleId} object containing the preview bundle ID.
763
+ * @returns {Promise<void>} Resolves once the preview switch is staged.
764
+ * @throws {Error} If preview sessions are disabled or the preview is not available locally.
765
+ * @since 8.49.0
766
+ */
767
+ setPreview(options: BundleId): Promise<void>;
768
+ /**
769
+ * Leave the active preview session and reload the saved live bundle.
770
+ *
771
+ * This does not delete any saved previews. Use {@link deletePreview} to remove
772
+ * a preview from local storage.
773
+ *
774
+ * @returns {Promise<void>} Resolves once the live bundle reload is staged.
775
+ * @throws {Error} If there is no preview fallback bundle available.
776
+ * @since 8.49.0
777
+ */
778
+ resetPreview(): Promise<void>;
779
+ /**
780
+ * Delete a locally saved preview and its bundle when possible.
781
+ *
782
+ * Active previews cannot be deleted until you switch away from them or call
783
+ * {@link resetPreview}. If only the preview metadata can be removed, the
784
+ * method still resolves with `deleted: false`.
785
+ *
786
+ * @param options A {@link BundleId} object containing the preview bundle ID.
787
+ * @returns {Promise<DeletePreviewResult>} Whether the underlying bundle was deleted.
788
+ * @throws {Error} If preview sessions are disabled.
789
+ * @since 8.49.0
790
+ */
791
+ deletePreview(options: BundleId): Promise<DeletePreviewResult>;
792
+ /**
793
+ * Check whether a saved preview's payload URL points to a newer preview bundle.
794
+ *
795
+ * Only previews started with a `payloadUrl` can be checked natively. Direct URL
796
+ * previews can still be switched or deleted locally, but the updater does not
797
+ * know where to check for newer versions.
798
+ *
799
+ * @param options A {@link BundleId} object containing the preview bundle ID.
800
+ * @returns {Promise<PreviewUpdateResult>} Update status for the preview.
801
+ * @throws {Error} If preview sessions are disabled or the preview has no payload URL.
802
+ * @since 8.49.0
803
+ */
804
+ checkPreviewUpdate(options: BundleId): Promise<PreviewUpdateResult>;
805
+ /**
806
+ * Download the newest bundle for a saved preview payload URL.
807
+ *
808
+ * If the preview being updated is active, the new bundle is applied and the
809
+ * WebView reloads. Otherwise, the saved preview entry is moved to the newly
810
+ * downloaded bundle and can be selected later with {@link setPreview}.
811
+ *
812
+ * @param options A {@link BundleId} object containing the preview bundle ID.
813
+ * @returns {Promise<PreviewUpdateResult>} The update result and saved preview metadata.
814
+ * @throws {Error} If preview sessions are disabled or the preview cannot be updated.
815
+ * @since 8.49.0
816
+ */
817
+ updatePreview(options: BundleId): Promise<PreviewUpdateResult>;
818
+ /**
819
+ * Delete a bundle from local storage to free up disk space.
820
+ *
821
+ * You cannot delete:
822
+ * - The currently active bundle
823
+ * - The `builtin` bundle (the version shipped with your app)
824
+ * - The bundle set as `next` (call {@link next} with a different bundle first)
825
+ *
826
+ * Use {@link list} to get all available bundle IDs.
827
+ *
828
+ * **Note:** The bundle ID is NOT the same as the version name.
829
+ * Use the `id` field from {@link BundleInfo}, not the `version` field.
830
+ *
831
+ * @param options A {@link BundleId} object containing the bundle ID to delete.
832
+ * @returns {Promise<void>} Resolves when the bundle is successfully deleted.
833
+ * @throws {Error} If the bundle is currently in use or doesn't exist.
834
+ */
835
+ delete(options: BundleId): Promise<void>;
836
+ /**
837
+ * Manually mark a bundle as failed/errored in manual update mode.
838
+ *
839
+ * This is useful when you detect that a bundle has critical issues and want to prevent
840
+ * it from being used again. The bundle status will be changed to `error` and the plugin
841
+ * will avoid using this bundle in the future.
842
+ *
843
+ * **Requirements:**
844
+ * - {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} must be set to `true`
845
+ * - Only works in manual update mode (when autoUpdate is disabled)
846
+ *
847
+ * Common use case: After downloading and testing a bundle, you discover it has critical
848
+ * bugs and want to mark it as failed so it won't be retried.
849
+ *
850
+ * @param options A {@link BundleId} object containing the bundle ID to mark as errored.
851
+ * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} with status set to `error`.
852
+ * @throws {Error} When the bundle does not exist or `allowManualBundleError` is false.
853
+ * @since 7.20.0
854
+ */
855
+ setBundleError(options: BundleId): Promise<BundleInfo>;
856
+ /**
857
+ * Get all locally downloaded bundles stored in your app.
858
+ *
859
+ * This returns all bundles that have been downloaded and are available locally, including:
860
+ * - The currently active bundle
861
+ * - The `builtin` bundle (shipped with your app)
862
+ * - Any downloaded bundles waiting to be activated
863
+ * - Failed bundles (with `error` status)
864
+ *
865
+ * Use this to:
866
+ * - Check available disk space by counting bundles
867
+ * - Delete old bundles with {@link delete}
868
+ * - Monitor bundle download status
869
+ *
870
+ * @param options The {@link ListOptions} for customizing the bundle list output.
871
+ * @returns {Promise<BundleListResult>} A promise containing the array of {@link BundleInfo} objects.
872
+ * @throws {Error} If the operation fails.
873
+ */
874
+ list(options?: ListOptions): Promise<BundleListResult>;
875
+ /**
876
+ * Reset the app to a known good bundle.
877
+ *
878
+ * This method helps recover from problematic updates by reverting to either:
879
+ * - The `builtin` bundle (the original version shipped with your app to App Store/Play Store)
880
+ * - The last successfully loaded bundle (most recent bundle that worked correctly)
881
+ *
882
+ * **IMPORTANT: This triggers an immediate app reload, destroying the current JavaScript context.**
883
+ * See {@link set} for details on the implications of this operation.
884
+ *
885
+ * Use cases:
886
+ * - Emergency recovery when an update causes critical issues
887
+ * - Testing rollback functionality
888
+ * - Providing users a "reset to factory" option
889
+ *
890
+ * @param options {@link ResetOptions} to control reset behavior.
891
+ * If `toLastSuccessful` is `false` (or omitted), resets to builtin.
892
+ * If `true`, resets to last successful bundle.
893
+ * If `usePendingBundle` is `true`, applies the pending bundle set via {@link next} and clears it.
894
+ * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
895
+ * @throws {Error} If the reset operation fails.
896
+ */
897
+ reset(options?: ResetOptions): Promise<void>;
898
+ /**
899
+ * Get information about the currently active bundle.
900
+ *
901
+ * Returns:
902
+ * - `bundle`: The currently active bundle information
903
+ * - `native`: The version of the builtin bundle (the original app version from App/Play Store)
904
+ *
905
+ * If no updates have been applied, `bundle.id` will be `"builtin"`, indicating the app
906
+ * is running the original version shipped with the native app.
907
+ *
908
+ * Use this to:
909
+ * - Display the current version to users
910
+ * - Check if an update is currently active
911
+ * - Compare against available updates
912
+ * - Log the active bundle for debugging
913
+ *
914
+ * @returns {Promise<CurrentBundleResult>} A promise with the current bundle and native version info.
915
+ * @throws {Error} If the operation fails.
916
+ */
917
+ current(): Promise<CurrentBundleResult>;
918
+ /**
919
+ * Manually reload the app to apply a pending update.
920
+ *
921
+ * This triggers the same reload behavior that happens automatically when the app backgrounds.
922
+ * If you've called {@link next} to queue an update, calling `reload()` will apply it immediately.
923
+ *
924
+ * **IMPORTANT: This destroys the current JavaScript context immediately.**
925
+ * See {@link set} for details on the implications of this operation.
926
+ *
927
+ * Common use cases:
928
+ * - Applying an update immediately after download instead of waiting for backgrounding
929
+ * - Providing a "Restart now" button to users after an update is ready
930
+ * - Testing update flows during development
931
+ *
932
+ * If no update is pending (no call to {@link next}), this simply reloads the current bundle.
933
+ * If `builtinMinimum` rejects a pending bundle below the native version, the promise rejects with
934
+ * code `VERSION_BELOW_NATIVE` and a message naming both versions. The current bundle and pending
935
+ * update remain unchanged, so you can reset to builtin or choose another bundle.
936
+ *
937
+ * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
938
+ * @throws {Error} If the reload operation fails.
939
+ */
940
+ reload(): Promise<void>;
941
+ /**
942
+ * Configure conditions that must be met before a pending update is applied.
943
+ *
944
+ * After calling {@link next} to queue an update, use this method to control when it gets applied.
945
+ * By default, the update is installed only after **all** specified conditions are satisfied (`conditionMode: 'and'`).
946
+ * Set `conditionMode` to `'or'` to apply the update as soon as **any** condition is met.
947
+ *
948
+ * Available condition types:
949
+ * - `background`: Wait until the app has spent more than the configured time in the background (see value formats below).
950
+ * - `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.
951
+ * - `date`: Wait until a specific date/time (ISO 8601 format)
952
+ * - `nativeVersion`: Wait until the native app is updated to a specific version
953
+ *
954
+ * Condition value formats:
955
+ * - `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.
956
+ * - `kill`: No value needed
957
+ * - `date`: ISO 8601 date string (e.g., `"2025-12-31T23:59:59Z"`)
958
+ * - `nativeVersion`: Version string (e.g., `"2.0.0"`)
959
+ *
960
+ * @example
961
+ * // Update after kill condition clears on launch AND background time exceeds 5 minutes
962
+ * await CapacitorUpdater.setMultiDelay({
963
+ * conditionMode: 'or',
964
+ * delayConditions: [
965
+ * { kind: 'kill' },
966
+ * { kind: 'background', value: '300000' }
967
+ * ]
968
+ * });
969
+ *
970
+ * @example
971
+ * // Update after a specific date
972
+ * await CapacitorUpdater.setMultiDelay({
973
+ * delayConditions: [{ kind: 'date', value: '2025-12-31T23:59:59Z' }]
974
+ * });
975
+ *
976
+ * @example
977
+ * // One background-and-return clears the condition; update installs on the next background
978
+ * await CapacitorUpdater.setMultiDelay({
979
+ * delayConditions: [{ kind: 'background' }]
980
+ * });
981
+ *
982
+ * @param options Contains the {@link MultiDelayConditions} array of conditions.
983
+ * @returns {Promise<void>} Resolves when the delay conditions are set.
984
+ * @throws {Error} If the operation fails or conditions are invalid.
985
+ * @since 4.3.0
986
+ */
987
+ setMultiDelay(options: MultiDelayConditions): Promise<void>;
988
+ /**
989
+ * Cancel all delay conditions and apply the pending update immediately.
990
+ *
991
+ * If you've set delay conditions with {@link setMultiDelay}, this method clears them
992
+ * and triggers the pending update to be applied on the next app background or restart.
993
+ *
994
+ * This is useful when:
995
+ * - User manually requests to update now (e.g., clicks "Update now" button)
996
+ * - Your app detects it's a good time to update (e.g., user finished critical task)
997
+ * - You want to override a time-based delay early
998
+ *
999
+ * @returns {Promise<void>} Resolves when the delay conditions are cleared.
1000
+ * @throws {Error} If the operation fails.
1001
+ * @since 4.0.0
1002
+ */
1003
+ cancelDelay(): Promise<void>;
1004
+ /**
1005
+ * Trigger the native auto-update check/download pipeline immediately.
1006
+ *
1007
+ * This starts the same background update flow used when the app moves to the
1008
+ * foreground with auto-update enabled. It is useful for native integrations
1009
+ * such as a silent push notification asking the app to check for a Capgo
1010
+ * bundle without reimplementing the update protocol in JavaScript.
1011
+ *
1012
+ * The promise resolves after the native background work has been queued, not
1013
+ * after the update has been downloaded or installed. Listen to `updaterEvent`:
1014
+ * its `updateCheckResult` type reports classified responses (`kind` with the
1015
+ * backend error or message), including blocked and up-to-date results, which
1016
+ * both emit `noNeedUpdate`. A successful offer of a new bundle is not always
1017
+ * classified: it can go straight to `download` and `updateAvailable` events
1018
+ * without an `updateCheckResult`, so do not wait for one after every check.
1019
+ * Use `updateAvailable`, `downloadComplete`, `downloadFailed`, and
1020
+ * `noNeedUpdate` for download and activation progress.
1021
+ *
1022
+ * Native support is available on iOS and Android. On Web, this method returns
1023
+ * a result with `status: 'unavailable'`. Native platforms also return
1024
+ * `unavailable` when the native auto-update system is disabled.
1025
+ *
1026
+ * @returns {Promise<TriggerUpdateCheckResult>} Whether a native update check was queued.
1027
+ */
1028
+ triggerUpdateCheck(): Promise<TriggerUpdateCheckResult>;
1029
+ /**
1030
+ * Check the update server for the latest available bundle version.
1031
+ *
1032
+ * This queries your configured update URL (or Capgo backend) to see if a newer bundle
1033
+ * is available for download. It does NOT download the bundle automatically.
1034
+ *
1035
+ * The response includes:
1036
+ * - `version`: The latest available version identifier
1037
+ * - `url`: Download URL for the bundle (if available)
1038
+ * - `breaking`: Whether this update is marked as incompatible (requires native app update)
1039
+ * - `message`: Optional message from the server
1040
+ * - `manifest`: File list for delta updates (if using multi-file downloads)
1041
+ *
1042
+ * After receiving the latest version info, you can:
1043
+ * 1. Compare it with your current version
1044
+ * 2. Download it using {@link download}
1045
+ * 3. Apply it using {@link next} or {@link set}
1046
+ *
1047
+ * **Important: Handling "no new version available"**
1048
+ *
1049
+ * When the device's current version matches the latest version on the server (i.e., the device is already
1050
+ * up-to-date), the server returns a 200 response with `error: "no_new_version_available"` and
1051
+ * `message: "No new version available"`. This is a normal, expected condition and resolves with
1052
+ * `kind: "up_to_date"` when the backend provides that classification.
1053
+ *
1054
+ * You should check `kind` and `error` before attempting to download:
1055
+ *
1056
+ * ```typescript
1057
+ * const latest = await CapacitorUpdater.getLatest();
1058
+ * if (latest.kind === 'up_to_date') {
1059
+ * console.log('Already up to date');
1060
+ * } else if (latest.kind === 'blocked') {
1061
+ * console.log('Update is blocked:', latest.error);
1062
+ * } else if (latest.url) {
1063
+ * // New version is available, proceed with download
1064
+ * }
1065
+ * ```
1066
+ *
1067
+ * In this scenario, the server:
1068
+ * - Logs the request with a "No new version available" message
1069
+ * - Sends a "noNew" stat action to track that the device checked for updates but was already current (done on the backend)
1070
+ *
1071
+ * @param options Optional {@link GetLatestOptions} to specify which channel to check.
1072
+ * @returns {Promise<LatestVersion>} Information about the latest available bundle version.
1073
+ * @throws {Error} Throws for failed update checks or transport/request failures.
1074
+ * @since 4.0.0
1075
+ */
1076
+ getLatest(options?: GetLatestOptions): Promise<LatestVersion>;
1077
+ /**
1078
+ * Return the manifest entries that still need to be downloaded for a partial update.
1079
+ *
1080
+ * Pass the result from {@link getLatest} directly when it includes a `manifest`.
1081
+ * The native plugin compares each manifest entry with the files already available
1082
+ * in the builtin bundle and the local delta cache. Entries that can be reused are
1083
+ * omitted from the returned `missing` list.
1084
+ *
1085
+ * For encrypted manifests, pass the `sessionKey` returned by {@link getLatest} so
1086
+ * encrypted file hashes can be checked against local files.
1087
+ *
1088
+ * ```typescript
1089
+ * const latest = await CapacitorUpdater.getLatest();
1090
+ * const missing = await CapacitorUpdater.getMissingBundleFiles(latest);
1091
+ * ```
1092
+ *
1093
+ * @param options A {@link GetMissingBundleFilesOptions} object, or a {@link LatestVersion} response containing `manifest`.
1094
+ * @returns {Promise<GetMissingBundleFilesResult>} The manifest entries that require network download.
1095
+ * @throws {Error} If the manifest is missing or invalid.
1096
+ * @since 8.47.0
1097
+ */
1098
+ getMissingBundleFiles(options: GetMissingBundleFilesOptions): Promise<GetMissingBundleFilesResult>;
1099
+ /**
1100
+ * Estimate the download size for manifest entries before downloading them.
1101
+ *
1102
+ * This method sends the provided manifest entries to the Capgo update endpoint
1103
+ * once and reads the stored manifest `file_size` metadata. It does not perform
1104
+ * per-file `HEAD` requests from the app.
1105
+ *
1106
+ * Use this after {@link getMissingBundleFiles} to estimate only the files this
1107
+ * device still needs:
1108
+ *
1109
+ * ```typescript
1110
+ * const latest = await CapacitorUpdater.getLatest();
1111
+ * const missing = await CapacitorUpdater.getMissingBundleFiles(latest);
1112
+ * const size = await CapacitorUpdater.getBundleDownloadSize({
1113
+ * version: latest.version,
1114
+ * manifest: missing.missing,
1115
+ * });
1116
+ * ```
1117
+ *
1118
+ * @param options A {@link GetBundleDownloadSizeOptions} object containing manifest entries.
1119
+ * @returns {Promise<GetBundleDownloadSizeResult>} Known byte totals and per-file size results.
1120
+ * @throws {Error} If the manifest is missing or invalid.
1121
+ * @since 8.47.0
1122
+ */
1123
+ getBundleDownloadSize(options: GetBundleDownloadSizeOptions): Promise<GetBundleDownloadSizeResult>;
1124
+ /**
1125
+ * Assign this device to a specific update channel at runtime.
1126
+ *
1127
+ * Channels allow you to distribute different bundle versions to different groups of users
1128
+ * (e.g., "production", "beta", "staging"). This method switches the device to a new channel.
1129
+ *
1130
+ * **Device Override UI:** `setChannel()` validates the channel with the backend, then stores the
1131
+ * selected channel locally on the device for future app restarts. It does not create or update
1132
+ * a backend Device Override, so the device will not appear as overridden in the Capgo dashboard.
1133
+ * Only assignments created from the dashboard or the Public API are shown in the Device Override UI.
1134
+ *
1135
+ * **Requirements:**
1136
+ * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)
1137
+ * - The backend may accept or reject the request based on channel settings
1138
+ *
1139
+ * **When to use:**
1140
+ * - After the app is ready and the user has interacted (e.g., opted into beta program)
1141
+ * - To implement in-app channel switching (beta toggle, tester access, etc.)
1142
+ * - For user-driven channel changes
1143
+ *
1144
+ * **When NOT to use:**
1145
+ * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead
1146
+ * - Before user interaction
1147
+ *
1148
+ * **Important: Listen for the `channelPrivate` event**
1149
+ *
1150
+ * When a user attempts to set a channel that doesn't allow device self-assignment, the method will
1151
+ * throw an error AND emit a `channelPrivate` {@link UpdaterEvent}. You should listen to this event
1152
+ * to provide appropriate feedback to users:
1153
+ *
1154
+ * ```typescript
1155
+ * CapacitorUpdater.addListener('updaterEvent', (event) => {
1156
+ * if (event.type === 'channelPrivate') {
1157
+ * console.warn(`Cannot access channel "${event.data.channel}": ${event.data.message}`);
1158
+ * // Show user-friendly message
1159
+ * }
1160
+ * });
1161
+ * ```
1162
+ *
1163
+ * This sends a request to the Capgo backend to validate the specified channel, then stores the
1164
+ * channel locally on the device for future app restarts.
1165
+ *
1166
+ * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.
1167
+ * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.
1168
+ * @throws {Error} If the channel doesn't exist or doesn't allow self-assignment.
1169
+ * @since 4.7.0
1170
+ */
1171
+ setChannel(options: SetChannelOptions): Promise<ChannelRes>;
1172
+ /**
1173
+ * Remove the plugin-managed local channel assignment and return to the default channel.
1174
+ *
1175
+ * This clears only the channel stored locally by {@link setChannel}; it does not delete Dashboard or Public API Device Override records. After the local assignment is cleared, normal channel precedence applies:
1176
+ * - An existing Dashboard or Public API Device Override, if one exists
1177
+ * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or
1178
+ * - Your backend default channel for this app
1179
+ *
1180
+ * Use this when:
1181
+ * - Users opt out of beta/testing programs
1182
+ * - You want to reset a device to standard update distribution
1183
+ * - Testing channel switching behavior
1184
+ *
1185
+ * @param options {@link UnsetChannelOptions} containing optional auto-update trigger.
1186
+ * @returns {Promise<void>} Resolves when the channel is successfully unset.
1187
+ * @throws {Error} If the operation fails.
1188
+ * @since 4.7.0
1189
+ */
1190
+ unsetChannel(options: UnsetChannelOptions): Promise<void>;
1191
+ /**
1192
+ * Get the current channel assigned to this device.
1193
+ *
1194
+ * Returns information about:
1195
+ * - `channel`: The currently assigned channel name (if any)
1196
+ * - `allowSet`: Whether the channel allows self-assignment
1197
+ * - `status`: Operation status
1198
+ * - `error`/`message`: Additional information (if applicable)
1199
+ *
1200
+ * Use this to:
1201
+ * - Display current channel to users (e.g., "You're on the Beta channel")
1202
+ * - Check if a device is on a specific channel before showing features
1203
+ * - Verify channel assignment after calling {@link setChannel}
1204
+ *
1205
+ * On native platforms, a successful response with a device channel override also refreshes the
1206
+ * default channel used by update checks. Responses with `status: 'default'` are reported only and
1207
+ * are not persisted. This refresh is persisted across app restarts.
1208
+ *
1209
+ * @returns {Promise<GetChannelRes>} The current channel information.
1210
+ * @throws {Error} If the operation fails.
1211
+ * @since 4.8.0
1212
+ */
1213
+ getChannel(): Promise<GetChannelRes>;
1214
+ /**
1215
+ * Get a list of all channels available for this device to self-assign to.
1216
+ *
1217
+ * Only returns channels where `allow_self_set` is `true`. These are channels that
1218
+ * users can switch to using {@link setChannel} without backend administrator intervention.
1219
+ *
1220
+ * Each channel includes:
1221
+ * - `id`: Unique channel identifier
1222
+ * - `name`: Human-readable channel name
1223
+ * - `public`: Whether the channel is publicly visible
1224
+ * - `allow_self_set`: Always `true` in results (filtered to only self-assignable channels)
1225
+ *
1226
+ * Use this to:
1227
+ * - Build a channel selector UI for users (e.g., "Join Beta" button)
1228
+ * - Show available testing/preview channels
1229
+ * - Implement channel discovery features
1230
+ *
1231
+ * @returns {Promise<ListChannelsResult>} List of channels the device can self-assign to.
1232
+ * @throws {Error} If the operation fails or the request to the backend fails.
1233
+ * @since 7.5.0
1234
+ */
1235
+ listChannels(): Promise<ListChannelsResult>;
1236
+ /**
1237
+ * Set a custom identifier for this device.
1238
+ *
1239
+ * This allows you to identify devices by your own custom ID (user ID, account ID, etc.)
1240
+ * instead of or in addition to the device's unique hardware ID. The custom ID is sent
1241
+ * to your update server and can be used for:
1242
+ * - Targeting specific users for updates
1243
+ * - Analytics and user tracking
1244
+ * - Debugging and support (correlating devices with users)
1245
+ * - A/B testing or feature flagging
1246
+ *
1247
+ * **Persistence:**
1248
+ * - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true` (the default), the ID persists across app restarts
1249
+ * - When `false`, the ID is only kept for the current session
1250
+ *
1251
+ * **Clearing the custom ID:**
1252
+ * - Pass an empty string `""` to remove any stored custom ID, even when persistence is disabled
1253
+ *
1254
+ * @param options The {@link SetCustomIdOptions} containing the custom identifier string.
1255
+ * @returns {Promise<void>} Resolves immediately (synchronous operation).
1256
+ * @throws {Error} If the operation fails.
1257
+ * @since 4.9.0
1258
+ */
1259
+ setCustomId(options: SetCustomIdOptions): Promise<void>;
1260
+ /**
1261
+ * Get the builtin bundle version (the original version shipped with your native app).
1262
+ *
1263
+ * This returns the version of the bundle that was included when the app was installed
1264
+ * from the App Store or Play Store. This is NOT the currently active bundle version -
1265
+ * use {@link current} for that.
1266
+ *
1267
+ * Returns:
1268
+ * - The {@link PluginsConfig.CapacitorUpdater.version} config value if set, or
1269
+ * - The native app version from platform configs (package.json, Info.plist, build.gradle)
1270
+ *
1271
+ * Use this to:
1272
+ * - Display the "factory" version to users
1273
+ * - Compare against downloaded bundle versions
1274
+ * - Determine if any updates have been applied
1275
+ * - Debugging version mismatches
1276
+ *
1277
+ * @returns {Promise<BuiltinVersion>} The builtin bundle version string.
1278
+ * @since 5.2.0
1279
+ */
1280
+ getBuiltinVersion(): Promise<BuiltinVersion>;
1281
+ /**
1282
+ * Get the unique, privacy-friendly identifier for this device.
1283
+ *
1284
+ * This ID is used to identify the device when communicating with update servers.
1285
+ * It's automatically generated and stored securely by the plugin.
1286
+ *
1287
+ * **Privacy & Security characteristics:**
1288
+ * - Generated as a UUID (not based on hardware identifiers)
1289
+ * - Stored securely in platform-specific secure storage
1290
+ * - Android: mirrored into backup-restorable app preferences for reinstall restore
1291
+ * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`
1292
+ * - Not synced to cloud (iOS)
1293
+ * - Follows Apple and Google privacy best practices
1294
+ * - Users can clear it via system settings (Android) or keychain access (iOS)
1295
+ *
1296
+ * **Persistence:**
1297
+ * The device ID persists across app reinstalls to maintain consistent device identity
1298
+ * for update tracking and analytics when platform storage is preserved. On Android,
1299
+ * apps with custom backup rules must keep the plugin app preferences eligible for
1300
+ * backup/restore; disabling Android backup or clearing app data creates a new ID.
1301
+ *
1302
+ * Use this to:
1303
+ * - Debug update delivery issues (check what ID the server sees)
1304
+ * - Implement device-specific features
1305
+ * - Correlate server logs with specific devices
1306
+ *
1307
+ * @returns {Promise<DeviceId>} The unique device identifier string.
1308
+ * @throws {Error} If the operation fails.
1309
+ */
1310
+ getDeviceId(): Promise<DeviceId>;
1311
+ /**
1312
+ * Get the version of the Capacitor Updater plugin installed in your app.
1313
+ *
1314
+ * This returns the version of the native plugin code (Android/iOS), which is sent
1315
+ * to the update server with each request. This is NOT your app version or bundle version.
1316
+ *
1317
+ * Use this to:
1318
+ * - Debug plugin-specific issues (when reporting bugs)
1319
+ * - Verify plugin installation and version
1320
+ * - Check compatibility with backend features
1321
+ * - Display in debug/about screens
1322
+ *
1323
+ * @returns {Promise<PluginVersion>} The Capacitor Updater plugin version string.
1324
+ * @throws {Error} If the operation fails.
1325
+ */
1326
+ getPluginVersion(): Promise<PluginVersion>;
1327
+ /**
1328
+ * Check if automatic updates are currently enabled.
1329
+ *
1330
+ * Returns `true` if {@link PluginsConfig.CapacitorUpdater.autoUpdate} is enabled,
1331
+ * meaning the plugin will automatically check for, download, and apply updates.
1332
+ *
1333
+ * Returns `false` if in manual mode, where you control the update flow using
1334
+ * {@link getLatest}, {@link download}, {@link next}, and {@link set}.
1335
+ *
1336
+ * Use this to:
1337
+ * - Determine which update flow your app is using
1338
+ * - Show/hide manual update UI based on mode
1339
+ * - Debug update behavior
1340
+ *
1341
+ * @returns {Promise<AutoUpdateEnabled>} `true` if auto-update is enabled, `false` if in manual mode.
1342
+ * @throws {Error} If the operation fails.
1343
+ */
1344
+ isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;
1345
+ /**
1346
+ * Remove all event listeners registered for this plugin.
1347
+ *
1348
+ * This unregisters every listener added via {@link addListener}, including all
1349
+ * `updaterEvent` listeners.
1350
+ *
1351
+ * Use this during cleanup (e.g., when unmounting components or closing screens)
1352
+ * to prevent memory leaks from lingering event listeners.
1353
+ *
1354
+ * @returns {Promise<void>} Resolves when all listeners are removed.
1355
+ * @since 1.0.0
1356
+ */
1357
+ removeAllListeners(): Promise<void>;
1358
+ /**
1359
+ * Listen for every updater event with a single listener.
1360
+ *
1361
+ * Each call receives `{ type, data }`: `type` is the event name and `data` is its payload
1362
+ * (see {@link UpdaterEvent} for every type and its payload).
1363
+ *
1364
+ * Since 9.0.0 this is the only listener the plugin emits. The per-event listeners
1365
+ * (`addListener('download', ...)`, `addListener('appReady', ...)`, ...) and the `majorAvailable`
1366
+ * alias were removed: switch on `event.type` instead.
1367
+ *
1368
+ * Some events are retained natively until a listener attaches: `set`, `appReady`, `noNeedUpdate`, and
1369
+ * `updateAvailable` from the automatic update when `autoUpdate` is `onlyDownload`. Do not rely on retention for an
1370
+ * `updateAvailable` from a manual `download()` (iOS does not retain it): register the listener before calling it.
1371
+ * The first `updaterEvent` listener receives every
1372
+ * retained event in emission order, so these are still delivered after a reload or a fast update check
1373
+ * even when the listener is registered later in app startup.
1374
+ *
1375
+ * ```typescript
1376
+ * CapacitorUpdater.addListener('updaterEvent', (event) => {
1377
+ * switch (event.type) {
1378
+ * case 'download':
1379
+ * console.log('progress', event.data.percent);
1380
+ * break;
1381
+ * case 'downloadFailed':
1382
+ * console.warn('download failed', event.data.version);
1383
+ * break;
1384
+ * case 'channelPrivate':
1385
+ * console.warn(`Cannot access channel "${event.data.channel}": ${event.data.message}`);
1386
+ * break;
1387
+ * }
1388
+ * });
1389
+ * ```
1390
+ *
1391
+ * @since 8.53.0
1392
+ */
1393
+ addListener(eventName: 'updaterEvent', listenerFunc: (event: UpdaterEvent) => void): Promise<PluginListenerHandle>;
1394
+ /**
1395
+ * Check if the auto-update feature is available (not disabled by custom server configuration).
1396
+ *
1397
+ * Returns `false` when a custom `updateUrl` is configured, as this typically indicates
1398
+ * you're using a self-hosted update server that may not support all auto-update features.
1399
+ *
1400
+ * Returns `true` when using the default Capgo backend or when the feature is available.
1401
+ *
1402
+ * This is different from {@link isAutoUpdateEnabled}:
1403
+ * - `isAutoUpdateEnabled()`: Checks if auto-update MODE is turned on/off
1404
+ * - `isAutoUpdateAvailable()`: Checks if auto-update is SUPPORTED with your current configuration
1405
+ *
1406
+ * @returns {Promise<AutoUpdateAvailable>} `false` when custom updateUrl is set, `true` otherwise.
1407
+ * @throws {Error} If the operation fails.
1408
+ */
1409
+ isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;
1410
+ /**
1411
+ * Get information about the bundle queued to be activated on next reload.
1412
+ *
1413
+ * Returns:
1414
+ * - {@link BundleInfo} object if a bundle has been queued via {@link next}
1415
+ * - `null` if no update is pending
1416
+ *
1417
+ * This is useful to:
1418
+ * - Check if an update is waiting to be applied
1419
+ * - Display "Update pending" status to users
1420
+ * - Show version info of the queued update
1421
+ * - Decide whether to show a "Restart to update" prompt
1422
+ *
1423
+ * The queued bundle will be activated when:
1424
+ * - The app is backgrounded (default behavior)
1425
+ * - The app is killed and restarted
1426
+ * - {@link reload} is called manually
1427
+ * - Delay conditions set by {@link setMultiDelay} are met
1428
+ *
1429
+ * @returns {Promise<BundleInfo | null>} The pending bundle info, or `null` if none is queued.
1430
+ * @throws {Error} If the operation fails.
1431
+ * @since 6.8.0
1432
+ */
1433
+ getNextBundle(): Promise<BundleInfo | null>;
1434
+ /**
1435
+ * Retrieve information about the most recent bundle that failed to load.
1436
+ *
1437
+ * When a bundle fails to load (e.g., JavaScript errors prevent initialization, missing files),
1438
+ * the plugin automatically rolls back and stores information about the failure. This method
1439
+ * retrieves that failure information.
1440
+ *
1441
+ * **IMPORTANT: The stored value is cleared after being retrieved once.**
1442
+ * Calling this method multiple times will only return the failure info on the first call,
1443
+ * then `null` on subsequent calls until another failure occurs.
1444
+ *
1445
+ * Returns:
1446
+ * - {@link UpdateFailedEvent} with bundle info if a failure was recorded
1447
+ * - `null` if no failure has occurred or if it was already retrieved
1448
+ *
1449
+ * Use this to:
1450
+ * - Show users why an update failed
1451
+ * - Log failure information for debugging
1452
+ * - Implement custom error handling/reporting
1453
+ * - Display rollback notifications
1454
+ *
1455
+ * @returns {Promise<UpdateFailedEvent | null>} The failed update info (cleared after first retrieval), or `null`.
1456
+ * @throws {Error} If the operation fails.
1457
+ * @since 7.22.0
1458
+ */
1459
+ getFailedUpdate(): Promise<UpdateFailedEvent | null>;
1460
+ /**
1461
+ * Enable or disable the native preview menu gesture.
1462
+ *
1463
+ * During preview sessions, users can use the configured native gesture to:
1464
+ * - Reload the current preview
1465
+ * - Leave the test app and return to the fallback bundle
1466
+ * - Switch update channel, when {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector} is also enabled
1467
+ *
1468
+ * Outside preview sessions, this preview menu is ignored. The channel selector can still be
1469
+ * shown outside preview sessions when {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector} is enabled.
1470
+ *
1471
+ * **Important:** Disable this in production builds or only enable for internal testers.
1472
+ *
1473
+ * This can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1474
+ * The native gesture is configured via {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}.
1475
+ *
1476
+ * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.
1477
+ * @returns {Promise<void>} Resolves when the setting is applied.
1478
+ * @throws {Error} If the operation fails.
1479
+ * @since 7.5.0
1480
+ */
1481
+ setShakeMenu(options: SetShakeMenuOptions): Promise<void>;
1482
+ /**
1483
+ * Check if the native preview menu gesture is currently enabled.
1484
+ *
1485
+ * Returns the current state of the shake menu feature that can be toggled via
1486
+ * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1487
+ *
1488
+ * Use this to:
1489
+ * - Check if debug features are enabled
1490
+ * - Show/hide debug settings UI
1491
+ * - Verify configuration during testing
1492
+ *
1493
+ * @returns {Promise<ShakeMenuEnabled>} Object with the current enabled state and gesture.
1494
+ * @throws {Error} If the operation fails.
1495
+ * @since 7.5.0
1496
+ */
1497
+ isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;
1498
+ /**
1499
+ * Enable or disable the channel selector menu gesture at runtime.
1500
+ *
1501
+ * When enabled, the configured native gesture can show a channel selector, including outside preview sessions.
1502
+ * If {@link setShakeMenu} is also enabled while a preview session is active, the shake menu includes
1503
+ * both preview actions and channel switching.
1504
+ *
1505
+ * This can also be configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
1506
+ * The native gesture is configured via {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}.
1507
+ *
1508
+ * @param options {@link SetShakeChannelSelectorOptions} with `enabled: true` to enable or `enabled: false` to disable.
1509
+ * @returns {Promise<void>} Resolves when the setting is applied.
1510
+ * @throws {Error} If the operation fails.
1511
+ * @since 8.43.0
1512
+ */
1513
+ setShakeChannelSelector(options: SetShakeChannelSelectorOptions): Promise<void>;
1514
+ /**
1515
+ * Check if the shake channel selector is currently enabled.
1516
+ *
1517
+ * Returns the current state of the shake channel selector feature that can be toggled via
1518
+ * {@link setShakeChannelSelector} or configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
1519
+ *
1520
+ * @returns {Promise<ShakeChannelSelectorEnabled>} Object with `enabled: true` or `enabled: false`.
1521
+ * @throws {Error} If the operation fails.
1522
+ * @since 8.43.0
1523
+ */
1524
+ isShakeChannelSelectorEnabled(): Promise<ShakeChannelSelectorEnabled>;
1525
+ /**
1526
+ * Get the currently configured App ID used for update server communication.
1527
+ *
1528
+ * Returns the App ID that identifies this app to the update server. This can be:
1529
+ * - The value set via {@link setAppId}, or
1530
+ * - The {@link PluginsConfig.CapacitorUpdater.appId} config value, or
1531
+ * - The default app identifier from your native app configuration
1532
+ *
1533
+ * Use this to:
1534
+ * - Verify which App ID is being used for updates
1535
+ * - Debug update delivery issues
1536
+ * - Display app configuration in debug screens
1537
+ * - Confirm App ID after calling {@link setAppId}
1538
+ *
1539
+ * @returns {Promise<GetAppIdRes>} Object containing the current `appId` string.
1540
+ * @throws {Error} If the operation fails.
1541
+ * @since 7.14.0
1542
+ */
1543
+ getAppId(): Promise<GetAppIdRes>;
1544
+ /**
1545
+ * Dynamically change the App ID used for update server communication.
1546
+ *
1547
+ * This overrides the App ID used to identify your app to the update server, allowing you
1548
+ * to switch between different app configurations at runtime (e.g., production vs staging
1549
+ * app IDs, or multi-tenant configurations).
1550
+ *
1551
+ * **Requirements:**
1552
+ * - {@link PluginsConfig.CapacitorUpdater.allowModifyAppId} must be set to `true`
1553
+ *
1554
+ * **Important considerations:**
1555
+ * - Changing the App ID will affect which updates this device receives
1556
+ * - The new App ID must exist on your update server
1557
+ * - This is primarily for advanced use cases (multi-tenancy, environment switching)
1558
+ * - Most apps should use the config-based {@link PluginsConfig.CapacitorUpdater.appId} instead
1559
+ *
1560
+ * @param options {@link SetAppIdOptions} containing the new App ID string.
1561
+ * @returns {Promise<void>} Resolves when the App ID is successfully changed.
1562
+ * @throws {Error} If `allowModifyAppId` is false or the operation fails.
1563
+ * @since 7.14.0
1564
+ */
1565
+ setAppId(options: SetAppIdOptions): Promise<void>;
1566
+ /**
1567
+ * Get information about the app's availability in the App Store or Play Store.
1568
+ *
1569
+ * This method checks the native app stores to see if a newer version of the app
1570
+ * is available for download. This is different from Capgo's OTA updates - this
1571
+ * checks for native app updates that require going through the app stores.
1572
+ *
1573
+ * **Platform differences:**
1574
+ * - **Android**: Uses Play Store's In-App Updates API for accurate update information
1575
+ * - **iOS**: Queries the App Store lookup API (requires country code for accurate results)
1576
+ *
1577
+ * **Returns information about:**
1578
+ * - Current installed version
1579
+ * - Available version in the store (if any)
1580
+ * - Whether an update is available
1581
+ * - Update priority (Android only)
1582
+ * - Whether immediate/flexible updates are allowed (Android only)
1583
+ *
1584
+ * Use this to:
1585
+ * - Check if users need to update from the app store
1586
+ * - Show "Update Available" prompts for native updates
1587
+ * - Implement version gating (require minimum native version)
1588
+ * - Combine with Capgo OTA updates for a complete update strategy
1589
+ *
1590
+ * @param options Optional {@link GetAppUpdateInfoOptions} with country code for iOS.
1591
+ * @returns {Promise<AppUpdateInfo>} Information about the current and available app versions.
1592
+ * @throws {Error} If the operation fails or store information is unavailable.
1593
+ * @since 8.0.0
1594
+ */
1595
+ getAppUpdateInfo(options?: GetAppUpdateInfoOptions): Promise<AppUpdateInfo>;
1596
+ /**
1597
+ * Open the app's page in the App Store or Play Store.
1598
+ *
1599
+ * This navigates the user to your app's store listing where they can manually
1600
+ * update the app. Use this as a fallback when in-app updates are not available
1601
+ * or when the user needs to update on iOS.
1602
+ *
1603
+ * **Platform behavior:**
1604
+ * - **Android**: Opens Play Store to the app's page
1605
+ * - **iOS**: Opens App Store to the app's page
1606
+ *
1607
+ * **Customization options:**
1608
+ * - `appId`: Specify a custom App Store ID (iOS) - useful for opening a different app's page
1609
+ * - `packageName`: Specify a custom package name (Android) - useful for opening a different app's page
1610
+ *
1611
+ * @param options Optional {@link OpenAppStoreOptions} to customize which app's store page to open.
1612
+ * @returns {Promise<void>} Resolves when the store is opened.
1613
+ * @throws {Error} If the store cannot be opened.
1614
+ * @since 8.0.0
1615
+ */
1616
+ openAppStore(options?: OpenAppStoreOptions): Promise<void>;
1617
+ /**
1618
+ * Perform an immediate in-app update on Android.
1619
+ *
1620
+ * This triggers Google Play's immediate update flow, which:
1621
+ * 1. Shows a full-screen update UI
1622
+ * 2. Downloads and installs the update
1623
+ * 3. Restarts the app automatically
1624
+ *
1625
+ * The user cannot continue using the app until the update is complete.
1626
+ * This is ideal for critical updates that must be installed immediately.
1627
+ *
1628
+ * **Requirements:**
1629
+ * - Android only (throws error on iOS)
1630
+ * - An update must be available (check with {@link getAppUpdateInfo} first)
1631
+ * - The update must allow immediate updates (`immediateUpdateAllowed: true`)
1632
+ *
1633
+ * **User experience:**
1634
+ * - Full-screen blocking UI
1635
+ * - Progress shown during download
1636
+ * - App automatically restarts after installation
1637
+ *
1638
+ * @returns {Promise<AppUpdateResult>} Result indicating success, cancellation, or failure.
1639
+ * @throws {Error} If not on Android, no update is available, or immediate updates not allowed.
1640
+ * @since 8.0.0
1641
+ */
1642
+ performImmediateUpdate(): Promise<AppUpdateResult>;
1643
+ /**
1644
+ * Start a flexible in-app update on Android.
1645
+ *
1646
+ * This triggers Google Play's flexible update flow, which:
1647
+ * 1. Downloads the update in the background
1648
+ * 2. Allows the user to continue using the app
1649
+ * 3. Notifies when download is complete
1650
+ * 4. Requires calling {@link completeFlexibleUpdate} to install
1651
+ *
1652
+ * Monitor the download progress with the `onFlexibleUpdateStateChange` type of `updaterEvent`.
1653
+ *
1654
+ * **Requirements:**
1655
+ * - Android only (throws error on iOS)
1656
+ * - An update must be available (check with {@link getAppUpdateInfo} first)
1657
+ * - The update must allow flexible updates (`flexibleUpdateAllowed: true`)
1658
+ *
1659
+ * **Typical flow:**
1660
+ * 1. Register `addListener('updaterEvent', ...)` and await it, handling `onFlexibleUpdateStateChange`
1661
+ * for progress, so no state change is missed
1662
+ * 2. Call `startFlexibleUpdate()` to begin download
1663
+ * 3. When status is `DOWNLOADED`, prompt user to restart
1664
+ * 4. Call `completeFlexibleUpdate()` to install and restart
1665
+ *
1666
+ * @returns {Promise<AppUpdateResult>} Result indicating the update was started, cancelled, or failed.
1667
+ * @throws {Error} If not on Android, no update is available, or flexible updates not allowed.
1668
+ * @since 8.0.0
1669
+ */
1670
+ startFlexibleUpdate(): Promise<AppUpdateResult>;
1671
+ /**
1672
+ * Complete a flexible in-app update on Android.
1673
+ *
1674
+ * After a flexible update has been downloaded (status `DOWNLOADED` in
1675
+ * `onFlexibleUpdateStateChange`), call this method to install the update
1676
+ * and restart the app.
1677
+ *
1678
+ * **Important:** This will immediately restart the app. Make sure to:
1679
+ * - Save any user data before calling
1680
+ * - Prompt the user before restarting
1681
+ * - Only call when the download status is `DOWNLOADED`
1682
+ *
1683
+ * @returns {Promise<void>} Resolves when the update installation begins (app will restart).
1684
+ * @throws {Error} If not on Android or no downloaded update is pending.
1685
+ * @since 8.0.0
1686
+ */
1687
+ completeFlexibleUpdate(): Promise<void>;
1688
+ }
1689
+ /**
1690
+ * pending: The bundle is pending to be **SET** as the next bundle.
1691
+ * downloading: The bundle is being downloaded.
1692
+ * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.
1693
+ * error: The bundle has failed to download.
1694
+ */
1695
+ export type BundleStatus = 'success' | 'error' | 'pending' | 'downloading' | 'deleted' | 'deleting';
1696
+ export type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';
1697
+ /**
1698
+ * Classification for update-check responses that do not provide a downloadable bundle.
1699
+ * The update backend provides this field directly. Missing or unknown values are treated as
1700
+ * failed by native clients.
1701
+ *
1702
+ * @since 8.45.11
1703
+ */
1704
+ export type UpdateResponseKind = 'up_to_date' | 'blocked' | 'failed';
1705
+ export interface NoNeedEvent {
1706
+ /**
1707
+ * Current status of download, between 0 and 100.
1708
+ *
1709
+ * @since 4.0.0
1710
+ */
1711
+ bundle: BundleInfo;
1712
+ }
1713
+ export interface UpdateCheckResultEvent {
1714
+ /**
1715
+ * Classification for the update check result, provided by the backend.
1716
+ *
1717
+ * @since 8.45.11
1718
+ */
1719
+ kind: UpdateResponseKind;
1720
+ /**
1721
+ * Backend error code, when provided.
1722
+ *
1723
+ * @since 8.45.11
1724
+ */
1725
+ error?: string;
1726
+ /**
1727
+ * Backend message, when provided.
1728
+ *
1729
+ * @since 8.45.11
1730
+ */
1731
+ message?: string;
1732
+ /**
1733
+ * HTTP status code returned by the update endpoint.
1734
+ *
1735
+ * @since 8.45.11
1736
+ */
1737
+ statusCode?: number;
1738
+ /**
1739
+ * Version referenced by the update check result.
1740
+ *
1741
+ * @since 8.45.11
1742
+ */
1743
+ version?: string;
1744
+ /**
1745
+ * Current bundle on the device.
1746
+ *
1747
+ * @since 8.45.11
1748
+ */
1749
+ bundle: BundleInfo;
1750
+ }
1751
+ export interface UpdateAvailableEvent {
1752
+ /**
1753
+ * Current status of download, between 0 and 100.
1754
+ *
1755
+ * @since 4.0.0
1756
+ */
1757
+ bundle: BundleInfo;
1758
+ }
1759
+ export interface ChannelRes {
1760
+ /**
1761
+ * Current status of set channel
1762
+ *
1763
+ * @since 4.7.0
1764
+ */
1765
+ status: string;
1766
+ error?: string;
1767
+ message?: string;
1768
+ }
1769
+ export interface GetChannelRes {
1770
+ /**
1771
+ * Current status of get channel
1772
+ *
1773
+ * @since 4.8.0
1774
+ */
1775
+ channel?: string;
1776
+ error?: string;
1777
+ message?: string;
1778
+ status?: string;
1779
+ allowSet?: boolean;
1780
+ }
1781
+ export interface ChannelInfo {
1782
+ /**
1783
+ * The channel ID
1784
+ *
1785
+ * @since 7.5.0
1786
+ */
1787
+ id: number;
1788
+ /**
1789
+ * The channel name
1790
+ *
1791
+ * @since 7.5.0
1792
+ */
1793
+ name: string;
1794
+ /**
1795
+ * Whether this is a public channel
1796
+ *
1797
+ * @since 7.5.0
1798
+ */
1799
+ public: boolean;
1800
+ /**
1801
+ * Whether devices can self-assign to this channel
1802
+ *
1803
+ * @since 7.5.0
1804
+ */
1805
+ allow_self_set: boolean;
1806
+ }
1807
+ export interface ListChannelsResult {
1808
+ /**
1809
+ * List of available channels
1810
+ *
1811
+ * @since 7.5.0
1812
+ */
1813
+ channels: ChannelInfo[];
1814
+ }
1815
+ export interface DownloadEvent {
1816
+ /**
1817
+ * Current status of download, between 0 and 100.
1818
+ *
1819
+ * @since 4.0.0
1820
+ */
1821
+ percent: number;
1822
+ bundle: BundleInfo;
1823
+ }
1824
+ /**
1825
+ * Payload of the `breakingAvailable` {@link UpdaterEvent}.
1826
+ *
1827
+ * @since 7.22.0
1828
+ */
1829
+ export interface BreakingAvailableEvent {
1830
+ /**
1831
+ * Version of the breaking update that the backend blocked for this native app.
1832
+ *
1833
+ * This is the target version when the backend sends one. When the backend omits it,
1834
+ * the native code can fall back to the current bundle version, so do not show this
1835
+ * value as the required upgrade without checking that it differs from the running bundle.
1836
+ *
1837
+ * @since 7.22.0
1838
+ */
1839
+ version: string;
1840
+ }
1841
+ export interface DownloadFailedEvent {
1842
+ /**
1843
+ * Emit when a download fail.
1844
+ *
1845
+ * @since 4.0.0
1846
+ */
1847
+ version: string;
1848
+ }
1849
+ export interface DownloadCompleteEvent {
1850
+ /**
1851
+ * Emit when a new update is available.
1852
+ *
1853
+ * @since 4.0.0
1854
+ */
1855
+ bundle: BundleInfo;
1856
+ }
1857
+ export interface UpdateFailedEvent {
1858
+ /**
1859
+ * Emit when a update failed to install.
1860
+ *
1861
+ * @since 4.0.0
1862
+ */
1863
+ bundle: BundleInfo;
1864
+ }
1865
+ export interface SetEvent {
1866
+ /**
1867
+ * Emit when a bundle has been applied successfully.
1868
+ * This event uses native `retainUntilConsumed` behavior.
1869
+ *
1870
+ * @since 8.43.12
1871
+ */
1872
+ bundle: BundleInfo;
1873
+ }
1874
+ export interface SetNextEvent {
1875
+ /**
1876
+ * Emit when a bundle is queued as the next bundle to install.
1877
+ *
1878
+ * @since 6.14.0
1879
+ */
1880
+ bundle: BundleInfo;
1881
+ }
1882
+ export interface AppReadyEvent {
1883
+ /**
1884
+ * Emitted when the app is ready to use.
1885
+ * This event uses native `retainUntilConsumed` behavior.
1886
+ *
1887
+ * @since 5.2.0
1888
+ */
1889
+ bundle: BundleInfo;
1890
+ status: string;
1891
+ }
1892
+ export interface ChannelPrivateEvent {
1893
+ /**
1894
+ * Emitted when attempting to set a channel that doesn't allow device self-assignment.
1895
+ *
1896
+ * @since 7.34.0
1897
+ */
1898
+ channel: string;
1899
+ message: string;
1900
+ }
1901
+ /**
1902
+ * Payload of the single `updaterEvent` listener: every plugin event as `{ type, data }`.
1903
+ * Switch on `type` to get a typed `data`.
1904
+ *
1905
+ * - `download`: download progress of a bundle, from start to finish (`percent` between 0 and 100).
1906
+ * - `noNeedUpdate`: the update pipeline run completed. It does not mean nothing is pending: a bundle can already be
1907
+ * downloaded and waiting (iOS can queue one to apply on background), so use `getNextBundle()` for what is queued
1908
+ * and `updateCheckResult.kind` for the backend's classification. `data.bundle` is usually the running
1909
+ * bundle, but after a download waiting on install conditions (for example `autoUpdate: 'always'` with delay
1910
+ * conditions) it is that downloaded bundle, not the active one; use `current()` for the running bundle.
1911
+ * It is not proof that no update existed (it also follows a blocked check and a background install).
1912
+ * Retained natively until a listener consumes it.
1913
+ * - `updateCheckResult`: classified result of an update check, before the updater decides whether to download.
1914
+ * In the background update pipeline, `up_to_date` and `blocked` are emitted before `noNeedUpdate` and no
1915
+ * `downloadFailed` follows. A `failed` result is emitted before `downloadFailed`, and native code sends an
1916
+ * `update_check_error` stat instead of `download_fail` because no bundle download was attempted.
1917
+ * Periodic checks (`periodCheckDelay`) may emit only `updateCheckResult`, without those follow-up events or stats.
1918
+ * - `updateAvailable`: a new bundle is downloaded and ready. When `autoUpdate` is `onlyDownload`, the one from the
1919
+ * automatic update is retained natively until a listener consumes it, because the app must apply that bundle
1920
+ * itself. Do not rely on retention for one from a manual `download()` (iOS does not retain it).
1921
+ * - `downloadComplete`: a bundle download finished.
1922
+ * - `downloadFailed`: a bundle download or update check failed.
1923
+ * - `breakingAvailable`: the backend blocked an update as incompatible with the current native app.
1924
+ * - `updateFailed`: a bundle failed its readiness check (no `notifyAppReady()` in time) and was rolled back. This happens
1925
+ * at the next app start or after an in-session reload (for example `set()`, `next()` applied on background, or an
1926
+ * instant apply update).
1927
+ * - `set`: a bundle was applied. Retained natively until a listener consumes it.
1928
+ * - `setNext`: a bundle was queued as the next bundle to install.
1929
+ * - `appReloaded`: the app reloaded.
1930
+ * - `appReady`: the app is ready to use. Retained natively until a listener consumes it.
1931
+ * - `channelPrivate`: `setChannel()` targeted a channel that does not allow device self-assignment.
1932
+ * - `onFlexibleUpdateStateChange`: Android flexible in-app update progress and install status.
1933
+ * `installStatus` is numeric: when it equals `FlexibleUpdateInstallStatus.DOWNLOADED` (`11`), prompt the user and call
1934
+ * {@link CapacitorUpdaterPlugin.completeFlexibleUpdate}.
1935
+ *
1936
+ * @since 8.53.0
1937
+ */
1938
+ export type UpdaterEvent = {
1939
+ type: 'download';
1940
+ data: DownloadEvent;
1941
+ } | {
1942
+ type: 'noNeedUpdate';
1943
+ data: NoNeedEvent;
1944
+ } | {
1945
+ type: 'updateCheckResult';
1946
+ data: UpdateCheckResultEvent;
1947
+ } | {
1948
+ type: 'updateAvailable';
1949
+ data: UpdateAvailableEvent;
1950
+ } | {
1951
+ type: 'downloadComplete';
1952
+ data: DownloadCompleteEvent;
1953
+ } | {
1954
+ type: 'downloadFailed';
1955
+ data: DownloadFailedEvent;
1956
+ } | {
1957
+ type: 'breakingAvailable';
1958
+ data: BreakingAvailableEvent;
1959
+ } | {
1960
+ type: 'updateFailed';
1961
+ data: UpdateFailedEvent;
1962
+ } | {
1963
+ type: 'set';
1964
+ data: SetEvent;
1965
+ } | {
1966
+ type: 'setNext';
1967
+ data: SetNextEvent;
1968
+ } | {
1969
+ type: 'appReloaded';
1970
+ data: Record<string, never>;
1971
+ } | {
1972
+ type: 'appReady';
1973
+ data: AppReadyEvent;
1974
+ } | {
1975
+ type: 'channelPrivate';
1976
+ data: ChannelPrivateEvent;
1977
+ } | {
1978
+ type: 'onFlexibleUpdateStateChange';
1979
+ data: FlexibleUpdateState;
1980
+ };
1981
+ /**
1982
+ * Every event name that can appear in {@link UpdaterEvent}.
1983
+ *
1984
+ * @since 8.53.0
1985
+ */
1986
+ export type UpdaterEventType = UpdaterEvent['type'];
1987
+ export interface ManifestEntry {
1988
+ file_name: string | null;
1989
+ file_hash: string | null;
1990
+ download_url: string | null;
1991
+ }
1992
+ export interface GetMissingBundleFilesOptions {
1993
+ /**
1994
+ * Manifest returned by {@link getLatest}. Passing the full {@link LatestVersion}
1995
+ * response is supported because it contains this field.
1996
+ *
1997
+ * @since 8.47.0
1998
+ */
1999
+ manifest?: ManifestEntry[];
2000
+ /**
2001
+ * Target bundle version. Passing the full {@link LatestVersion} response is
2002
+ * supported because it contains this field.
2003
+ *
2004
+ * @since 8.47.0
2005
+ */
2006
+ version?: string;
2007
+ /**
2008
+ * Session key returned by {@link getLatest}, required only when file hashes are encrypted.
2009
+ *
2010
+ * @since 8.47.0
2011
+ */
2012
+ sessionKey?: string;
2013
+ }
2014
+ export interface GetMissingBundleFilesResult {
2015
+ /**
2016
+ * Entries that are not available locally and need to be downloaded.
2017
+ *
2018
+ * @since 8.47.0
2019
+ */
2020
+ missing: ManifestEntry[];
2021
+ /**
2022
+ * Total entries in the provided manifest.
2023
+ *
2024
+ * @since 8.47.0
2025
+ */
2026
+ total: number;
2027
+ /**
2028
+ * Number of entries that need to be downloaded.
2029
+ *
2030
+ * @since 8.47.0
2031
+ */
2032
+ missingCount: number;
2033
+ /**
2034
+ * Number of entries that can be reused from builtin files or local cache.
2035
+ *
2036
+ * @since 8.47.0
2037
+ */
2038
+ reusableCount: number;
2039
+ }
2040
+ export interface GetBundleDownloadSizeOptions {
2041
+ /**
2042
+ * Manifest entries to estimate. Pass `missing.missing` from {@link getMissingBundleFiles}
2043
+ * to estimate only the bytes this device still needs to download.
2044
+ *
2045
+ * @since 8.47.0
2046
+ */
2047
+ manifest?: ManifestEntry[];
2048
+ /**
2049
+ * Target bundle version. Pass `latest.version` when estimating files returned
2050
+ * by {@link getLatest}.
2051
+ *
2052
+ * @since 8.47.0
2053
+ */
2054
+ version?: string;
2055
+ }
2056
+ export interface BundleFileSize {
2057
+ /**
2058
+ * File name from the manifest entry.
2059
+ *
2060
+ * @since 8.47.0
2061
+ */
2062
+ file_name: string | null;
2063
+ /**
2064
+ * File hash from the manifest entry.
2065
+ *
2066
+ * @since 8.47.0
2067
+ */
2068
+ file_hash: string | null;
2069
+ /**
2070
+ * Download URL from the manifest entry.
2071
+ *
2072
+ * @since 8.47.0
2073
+ */
2074
+ download_url: string | null;
119
2075
  /**
120
- * Current status of get channel
2076
+ * Estimated bytes to download when the server exposes a size.
121
2077
  *
122
- * @since 4.8.0
2078
+ * @since 8.47.0
123
2079
  */
124
- channel?: string;
125
- error?: any;
126
- message?: any;
127
- status?: string;
128
- allowSet?: boolean;
129
- }
130
- export interface DownloadEvent {
2080
+ size?: number;
131
2081
  /**
132
- * Current status of download, between 0 and 100.
2082
+ * Error for this entry when the size could not be determined.
133
2083
  *
134
- * @since 4.0.0
2084
+ * @since 8.47.0
135
2085
  */
136
- percent: number;
137
- bundle: BundleInfo;
2086
+ error?: string;
138
2087
  }
139
- export interface MajorAvailableEvent {
2088
+ export interface GetBundleDownloadSizeResult {
140
2089
  /**
141
- * Emit when a new major bundle is available.
2090
+ * Sum of all known file sizes in bytes.
142
2091
  *
143
- * @since 4.0.0
2092
+ * @since 8.47.0
144
2093
  */
145
- version: string;
146
- }
147
- export interface DownloadFailedEvent {
2094
+ totalSize: number;
148
2095
  /**
149
- * Emit when a download fail.
2096
+ * Number of files with a known size.
150
2097
  *
151
- * @since 4.0.0
2098
+ * @since 8.47.0
152
2099
  */
153
- version: string;
154
- }
155
- export interface DownloadCompleteEvent {
2100
+ knownFiles: number;
156
2101
  /**
157
- * Emit when a new update is available.
2102
+ * Number of files whose size could not be determined.
158
2103
  *
159
- * @since 4.0.0
2104
+ * @since 8.47.0
160
2105
  */
161
- bundle: BundleInfo;
162
- }
163
- export interface UpdateFailedEvent {
2106
+ unknownFiles: number;
164
2107
  /**
165
- * Emit when a update failed to install.
2108
+ * Per-file size results.
166
2109
  *
167
- * @since 4.0.0
2110
+ * @since 8.47.0
168
2111
  */
169
- bundle: BundleInfo;
2112
+ files: BundleFileSize[];
170
2113
  }
171
- export interface latestVersion {
2114
+ export interface LatestVersion {
172
2115
  /**
173
- * Res of getLatest method
2116
+ * Result of getLatest method
174
2117
  *
175
2118
  * @since 4.0.0
176
2119
  */
177
2120
  version: string;
178
- major?: boolean;
2121
+ /**
2122
+ * @since 6
2123
+ */
2124
+ checksum?: string;
2125
+ /**
2126
+ * Indicates whether the update was flagged as breaking by the backend.
2127
+ *
2128
+ * @since 7.22.0
2129
+ */
2130
+ breaking?: boolean;
2131
+ /**
2132
+ * Optional message from the server.
2133
+ * When no new version is available, this will be "No new version available".
2134
+ */
179
2135
  message?: string;
180
2136
  sessionKey?: string;
2137
+ /**
2138
+ * Error code from the server, if any. Use `kind` for classification instead of parsing this value.
2139
+ */
181
2140
  error?: string;
2141
+ /**
2142
+ * Classification for this response, provided by the backend.
2143
+ *
2144
+ * @since 8.45.11
2145
+ */
2146
+ kind?: UpdateResponseKind;
2147
+ /**
2148
+ * HTTP status code returned by the update server for classified update-check responses.
2149
+ *
2150
+ * @since 8.45.11
2151
+ */
2152
+ statusCode?: number;
2153
+ /**
2154
+ * The previous/current version name (provided for reference).
2155
+ */
182
2156
  old?: string;
2157
+ /**
2158
+ * Download URL for the bundle (when a new version is available).
2159
+ */
183
2160
  url?: string;
2161
+ /**
2162
+ * File list for delta updates (when using multi-file downloads).
2163
+ * @since 6.1
2164
+ */
2165
+ manifest?: ManifestEntry[];
2166
+ /**
2167
+ * Missing manifest entries for this device when {@link GetLatestOptions.includeBundleSize}
2168
+ * is enabled.
2169
+ *
2170
+ * @since 8.47.0
2171
+ */
2172
+ missing?: GetMissingBundleFilesResult;
2173
+ /**
2174
+ * Estimated download size for missing manifest entries when
2175
+ * {@link GetLatestOptions.includeBundleSize} is enabled.
2176
+ *
2177
+ * @since 8.47.0
2178
+ */
2179
+ downloadSize?: GetBundleDownloadSizeResult;
2180
+ /**
2181
+ * Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release).
2182
+ * @since 7.35.0
2183
+ */
2184
+ link?: string;
2185
+ /**
2186
+ * Optional comment or description for this bundle version.
2187
+ * @since 7.35.0
2188
+ */
2189
+ comment?: string;
184
2190
  }
185
2191
  export interface BundleInfo {
186
2192
  id: string;
@@ -191,8 +2197,15 @@ export interface BundleInfo {
191
2197
  }
192
2198
  export interface SetChannelOptions {
193
2199
  channel: string;
2200
+ triggerAutoUpdate?: boolean;
2201
+ }
2202
+ export interface UnsetChannelOptions {
2203
+ triggerAutoUpdate?: boolean;
194
2204
  }
195
2205
  export interface SetCustomIdOptions {
2206
+ /**
2207
+ * Custom identifier to associate with the device. Use an empty string to clear any saved value.
2208
+ */
196
2209
  customId: string;
197
2210
  }
198
2211
  export interface DelayCondition {
@@ -203,251 +2216,654 @@ export interface DelayCondition {
203
2216
  kind: DelayUntilNext;
204
2217
  value?: string;
205
2218
  }
206
- export type BundleStatus = "success" | "error" | "pending" | "downloading";
207
- export type DelayUntilNext = "background" | "kill" | "nativeVersion" | "date";
208
- export type DownloadChangeListener = (state: DownloadEvent) => void;
209
- export type NoNeedListener = (state: noNeedEvent) => void;
210
- export type UpdateAvailabledListener = (state: updateAvailableEvent) => void;
211
- export type DownloadFailedListener = (state: DownloadFailedEvent) => void;
212
- export type DownloadCompleteListener = (state: DownloadCompleteEvent) => void;
213
- export type MajorAvailableListener = (state: MajorAvailableEvent) => void;
214
- export type UpdateFailedListener = (state: UpdateFailedEvent) => void;
215
- export type AppReloadedListener = (state: void) => void;
216
- export interface CapacitorUpdaterPlugin {
2219
+ export interface GetLatestOptions {
2220
+ /**
2221
+ * The channel to get the latest version for
2222
+ * The channel must allow 'self_assign' for this to work
2223
+ * @since 6.8.0
2224
+ * @default undefined
2225
+ */
2226
+ channel?: string;
217
2227
  /**
218
- * Notify Capacitor Updater that the current bundle is working (a rollback will occur of this method is not called on every app launch)
219
- * By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur.
220
- * Change this behaviour with {@link appReadyTimeout}
2228
+ * Temporarily use another app id for this update check while using a trusted preview container.
2229
+ * This only changes the app id sent by this request; it does not persist a preview session.
2230
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
2231
+ * @since 8.47.0
2232
+ * @default undefined
2233
+ */
2234
+ appId?: string;
2235
+ /**
2236
+ * When true, the native plugin computes which manifest files are missing on
2237
+ * this device and asks the Capgo update endpoint for their stored sizes before
2238
+ * resolving {@link getLatest}.
221
2239
  *
222
- * @returns {Promise<BundleInfo>} an Promise resolved directly
223
- * @throws An error if something went wrong
2240
+ * This adds one backend request only when the update response contains a
2241
+ * manifest. It does not perform per-file network checks.
2242
+ *
2243
+ * @since 8.47.0
2244
+ * @default false
2245
+ */
2246
+ includeBundleSize?: boolean;
2247
+ }
2248
+ export interface StartPreviewSessionOptions {
2249
+ /**
2250
+ * App id to use while the preview session is active.
2251
+ * The previous app id is restored when leaving the preview session.
2252
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
2253
+ * @since 8.47.0
2254
+ * @default undefined
2255
+ */
2256
+ appId?: string;
2257
+ /**
2258
+ * HTTP(S) URL returning a preview download payload.
2259
+ * When provided, the native shake reload action fetches this payload again
2260
+ * before reloading so channel previews can move to the latest bundle.
2261
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
2262
+ * @since 8.48.0
2263
+ * @default undefined
2264
+ */
2265
+ payloadUrl?: string;
2266
+ /**
2267
+ * Human-readable preview name stored with the next preview bundle applied by
2268
+ * {@link set}. Native preview menus and {@link listPreviews} can display it.
2269
+ * @since 8.49.0
2270
+ * @default undefined
2271
+ */
2272
+ name?: string;
2273
+ /**
2274
+ * Optional source label for the preview, such as `channel`, `bundle`, `url`,
2275
+ * or `payload`. This is stored as metadata only.
2276
+ * @since 8.49.0
2277
+ * @default undefined
224
2278
  */
225
- notifyAppReady(): Promise<BundleInfo>;
2279
+ source?: string;
2280
+ }
2281
+ export interface PreviewInfo {
226
2282
  /**
227
- * 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
2283
+ * Preview bundle id.
228
2284
  *
229
- * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.
230
- * @param url 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.)
231
- * @param version set the version code/name of this bundle/version
232
- * @example https://example.com/versions/{version}/dist.zip
2285
+ * @since 8.49.0
233
2286
  */
234
- download(options: {
235
- url: string;
236
- version: string;
237
- sessionKey?: string;
238
- checksum?: string;
239
- }): Promise<BundleInfo>;
2287
+ id: string;
240
2288
  /**
241
- * Set the next bundle to be used when the app is reloaded.
2289
+ * Locally downloaded bundle backing this preview.
242
2290
  *
243
- * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle id.
244
- * @param id The bundle id to set as current, next time the app is reloaded. See {@link BundleInfo.id}
245
- * @throws An error if there are is no index.html file inside the bundle folder.
2291
+ * @since 8.49.0
246
2292
  */
247
- next(options: {
248
- id: string;
249
- }): Promise<BundleInfo>;
2293
+ bundle: BundleInfo;
250
2294
  /**
251
- * Set the current bundle and immediately reloads the app.
2295
+ * Human-readable name supplied when the preview was started.
252
2296
  *
253
- * @param id The bundle id to set as current. See {@link BundleInfo.id}
254
- * @returns {Promise<Void>} An empty promise.
255
- * @throws An error if there are is no index.html file inside the bundle folder.
2297
+ * @since 8.49.0
256
2298
  */
257
- set(options: {
258
- id: string;
259
- }): Promise<void>;
2299
+ name?: string;
260
2300
  /**
261
- * Delete bundle in storage
2301
+ * Metadata source label supplied when the preview was started.
262
2302
  *
263
- * @returns {Promise<void>} an empty Promise when the bundle is deleted
264
- * @param id The bundle id to delete (note, this is the bundle id, NOT the version name)
265
- * @throws An error if the something went wrong
2303
+ * @since 8.49.0
266
2304
  */
267
- delete(options: {
268
- id: string;
269
- }): Promise<void>;
2305
+ source?: string;
270
2306
  /**
271
- * Get all available bundles
2307
+ * Preview app id, when the session uses an app id override.
272
2308
  *
273
- * @returns {Promise<{bundles: BundleInfo[]}>} an Promise witht the bundles list
274
- * @throws An error if the something went wrong
2309
+ * @since 8.49.0
275
2310
  */
276
- list(): Promise<{
277
- bundles: BundleInfo[];
278
- }>;
2311
+ appId?: string;
279
2312
  /**
280
- * Set the `builtin` bundle (the one sent to Apple store / Google play store ) as current bundle
2313
+ * Payload URL used to refresh this preview.
281
2314
  *
282
- * @returns {Promise<void>} an empty Promise
283
- * @param toLastSuccessful [false] if yes it reset to to the last successfully loaded bundle instead of `builtin`
284
- * @throws An error if the something went wrong
2315
+ * @since 8.49.0
285
2316
  */
286
- reset(options?: {
287
- toLastSuccessful?: boolean;
288
- }): Promise<void>;
2317
+ payloadUrl?: string;
289
2318
  /**
290
- * Get the current bundle, if none are set it returns `builtin`, currentNative is the original bundle installed on the device
2319
+ * ISO timestamp for when this preview was first saved.
291
2320
  *
292
- * @returns {Promise<{ bundle: BundleInfo, native: string }>} an Promise with the current bundle info
293
- * @throws An error if the something went wrong
2321
+ * @since 8.49.0
294
2322
  */
295
- current(): Promise<{
296
- bundle: BundleInfo;
297
- native: string;
298
- }>;
2323
+ createdAt: string;
299
2324
  /**
300
- * Reload the view
2325
+ * ISO timestamp for the last metadata or bundle update.
301
2326
  *
302
- * @returns {Promise<void>} an Promise resolved when the view is reloaded
303
- * @throws An error if the something went wrong
2327
+ * @since 8.49.0
304
2328
  */
305
- reload(): Promise<void>;
2329
+ updatedAt: string;
306
2330
  /**
307
- * Set DelayCondition, skip updates until one of the conditions is met
2331
+ * ISO timestamp for the last time this preview was activated.
308
2332
  *
309
- * @returns {Promise<void>} an Promise resolved directly
310
- * @param options are the {@link DelayCondition} list to set
2333
+ * @since 8.49.0
2334
+ */
2335
+ lastUsedAt: string;
2336
+ /**
2337
+ * Whether this preview is the currently active bundle in a preview session.
311
2338
  *
312
- * @example
313
- * setMultiDelay({ delayConditions: [{ kind: 'kill' }, { kind: 'background', value: '300000' }] })
314
- * // installs the update after the user kills the app or after a background of 300000 ms (5 minutes)
2339
+ * @since 8.49.0
2340
+ */
2341
+ isActive: boolean;
2342
+ }
2343
+ export interface PreviewListResult {
2344
+ /**
2345
+ * Locally available preview bundles.
315
2346
  *
316
- * @example
317
- * setMultiDelay({ delayConditions: [{ kind: 'date', value: '2022-09-14T06:14:11.920Z' }] })
318
- * // installs the update after the specific iso8601 date is expired
2347
+ * @since 8.49.0
2348
+ */
2349
+ previews: PreviewInfo[];
2350
+ /**
2351
+ * Current preview when a preview session is active.
319
2352
  *
320
- * @example
321
- * setMultiDelay({ delayConditions: [{ kind: 'background' }] })
322
- * // installs the update after the the first background (default behaviour without setting delay)
2353
+ * @since 8.49.0
2354
+ */
2355
+ current?: PreviewInfo;
2356
+ /**
2357
+ * Bundle currently loaded by the WebView.
323
2358
  *
324
- * @throws An error if the something went wrong
325
- * @since 4.3.0
2359
+ * @since 8.49.0
326
2360
  */
327
- setMultiDelay(options: {
328
- delayConditions: DelayCondition[];
329
- }): Promise<void>;
2361
+ currentBundle: BundleInfo;
330
2362
  /**
331
- * Cancel delay to updates as usual
2363
+ * Bundle that will be restored when leaving preview mode.
332
2364
  *
333
- * @returns {Promise<void>} an Promise resolved directly
334
- * @throws An error if the something went wrong
335
- * @since 4.0.0
2365
+ * @since 8.49.0
336
2366
  */
337
- cancelDelay(): Promise<void>;
2367
+ liveBundle?: BundleInfo;
2368
+ }
2369
+ export interface DeletePreviewResult {
338
2370
  /**
339
- * Get Latest bundle available from update Url
2371
+ * Whether preview metadata was removed.
340
2372
  *
341
- * @returns {Promise<latestVersion>} an Promise resolved when url is loaded
342
- * @throws An error if the something went wrong
343
- * @since 4.0.0
2373
+ * @since 8.49.0
344
2374
  */
345
- getLatest(): Promise<latestVersion>;
2375
+ removed: boolean;
346
2376
  /**
347
- * Set Channel for this device
2377
+ * Whether the underlying local bundle was deleted.
348
2378
  *
349
- * @returns {Promise<channelRes>} an Promise resolved when channel is set
350
- * @param options is the {@link SetChannelOptions} channel to set
351
- * @throws An error if the something went wrong
352
- * @since 4.7.0
2379
+ * @since 8.49.0
353
2380
  */
354
- setChannel(options: SetChannelOptions): Promise<channelRes>;
2381
+ deleted: boolean;
2382
+ }
2383
+ export interface PreviewUpdateResult {
355
2384
  /**
356
- * get Channel for this device
2385
+ * Saved preview metadata after the check or update.
357
2386
  *
358
- * @returns {Promise<channelRes>} an Promise resolved with channel info
359
- * @throws An error if the something went wrong
360
- * @since 4.8.0
2387
+ * @since 8.49.0
361
2388
  */
362
- getChannel(): Promise<getChannelRes>;
2389
+ preview: PreviewInfo;
363
2390
  /**
364
- * Set Channel for this device
2391
+ * Latest version returned by the preview payload endpoint.
365
2392
  *
366
- * @returns {Promise<void>} an Promise resolved instantly
367
- * @param options is the {@link SetCustomIdOptions} customId to set
368
- * @throws An error if the something went wrong
369
- * @since 4.9.0
2393
+ * @since 8.49.0
370
2394
  */
371
- setCustomId(options: SetCustomIdOptions): Promise<void>;
2395
+ latestVersion?: string;
372
2396
  /**
373
- * Listen for download event in the App, let you know when the download is started, loading and finished
2397
+ * Whether the saved preview already matches the latest payload version.
374
2398
  *
375
- * @since 2.0.11
2399
+ * @since 8.49.0
376
2400
  */
377
- addListener(eventName: "download", listenerFunc: DownloadChangeListener): Promise<PluginListenerHandle> & PluginListenerHandle;
2401
+ upToDate: boolean;
378
2402
  /**
379
- * Listen for no need to update event, usefull when you want force check every time the app is launched
2403
+ * Whether a newer bundle was downloaded and saved.
380
2404
  *
381
- * @since 4.0.0
2405
+ * @since 8.49.0
382
2406
  */
383
- addListener(eventName: "noNeedUpdate", listenerFunc: NoNeedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
2407
+ updated: boolean;
384
2408
  /**
385
- * Listen for availbale update event, usefull when you want to force check every time the app is launched
2409
+ * New bundle when {@link updatePreview} downloaded one.
386
2410
  *
2411
+ * @since 8.49.0
2412
+ */
2413
+ bundle?: BundleInfo;
2414
+ }
2415
+ export interface AppReadyResult {
2416
+ bundle: BundleInfo;
2417
+ }
2418
+ export interface UpdateUrl {
2419
+ url: string;
2420
+ }
2421
+ export interface StatsUrl {
2422
+ url: string;
2423
+ }
2424
+ export interface ChannelUrl {
2425
+ url: string;
2426
+ }
2427
+ /**
2428
+ * This URL and versions are used to download the bundle from the server, If you use backend all information will be given by the method getLatest.
2429
+ * If you don't use backend, you need to provide the URL and version of the bundle. Encrypted ZIP downloads require checksum and sessionKey. Encrypted manifest downloads require
2430
+ * sessionKey and a signed file_hash for each manifest entry. For updater 9, take them from the Capgo CLI upload flow, which produces the v9 checksum format when it
2431
+ * detects updater 9 in the project; see "Migration to v9" in the README. A standalone encrypt command may not produce it.
2432
+ */
2433
+ export interface DownloadOptions {
2434
+ /**
2435
+ * 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.)
2436
+ */
2437
+ url: string;
2438
+ /**
2439
+ * The version code/name of this bundle/version
2440
+ */
2441
+ version: string;
2442
+ /**
2443
+ * The session key for the update, when the bundle is encrypted with a session key
387
2444
  * @since 4.0.0
2445
+ * @default undefined
388
2446
  */
389
- addListener(eventName: "updateAvailable", listenerFunc: UpdateAvailabledListener): Promise<PluginListenerHandle> & PluginListenerHandle;
2447
+ sessionKey?: string;
390
2448
  /**
391
- * Listen for download event in the App, let you know when the download is started, loading and finished
2449
+ * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted.
392
2450
  *
2451
+ * Since 9.0.0, the checksum of an encrypted bundle must sign both the SHA-256 of the bundle zip and the
2452
+ * SHA-256 of the encrypted bytes. The plugin checks the downloaded bytes against it before decrypting them.
2453
+ * The Capgo CLI upload flow produces this format when it detects updater 9 in the project; for self-hosted
2454
+ * updates, follow "Migration to v9" in the README instead of relying on a standalone encrypt command.
393
2455
  * @since 4.0.0
2456
+ * @default undefined
2457
+ */
2458
+ checksum?: string;
2459
+ /**
2460
+ * The manifest for multi-file downloads
2461
+ * @since 6.1.0
2462
+ * @default undefined
2463
+ */
2464
+ manifest?: ManifestEntry[];
2465
+ }
2466
+ export interface BundleId {
2467
+ id: string;
2468
+ }
2469
+ export interface BundleListResult {
2470
+ bundles: BundleInfo[];
2471
+ }
2472
+ export interface ResetOptions {
2473
+ /**
2474
+ * Reset to the last successfully loaded bundle instead of the builtin one.
2475
+ * @default false
394
2476
  */
395
- addListener(eventName: "downloadComplete", listenerFunc: DownloadCompleteListener): Promise<PluginListenerHandle> & PluginListenerHandle;
2477
+ toLastSuccessful?: boolean;
396
2478
  /**
397
- * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
2479
+ * Apply the pending bundle set via {@link next} while resetting.
398
2480
  *
399
- * @since 2.3.0
2481
+ * When `true`, the plugin will switch to the pending bundle immediately and clear the pending flag.
2482
+ * If no pending bundle exists, the reset will fail.
2483
+ * @default false
2484
+ */
2485
+ usePendingBundle?: boolean;
2486
+ }
2487
+ export interface ListOptions {
2488
+ /**
2489
+ * Whether to return the raw bundle list or the manifest. If true, the list will attempt to read the internal database instead of files on disk.
2490
+ * @since 6.14.0
2491
+ * @default false
400
2492
  */
401
- addListener(eventName: "majorAvailable", listenerFunc: MajorAvailableListener): Promise<PluginListenerHandle> & PluginListenerHandle;
2493
+ raw?: boolean;
2494
+ }
2495
+ export interface CurrentBundleResult {
2496
+ bundle: BundleInfo;
2497
+ native: string;
2498
+ }
2499
+ /**
2500
+ * How multiple delay conditions are combined when more than one is set.
2501
+ *
2502
+ * - `and`: every condition must be satisfied before the pending update is applied (default, backward compatible).
2503
+ * - `or`: the pending update is applied as soon as any condition is satisfied.
2504
+ *
2505
+ * @since 8.50.0
2506
+ */
2507
+ export type DelayConditionMode = 'and' | 'or';
2508
+ export interface MultiDelayConditions {
2509
+ delayConditions: DelayCondition[];
402
2510
  /**
403
- * Listen for update fail event in the App, let you know when update has fail to install at next app start
2511
+ * How to combine multiple delay conditions.
404
2512
  *
405
- * @since 2.3.0
2513
+ * @default 'and'
2514
+ * @since 8.50.0
2515
+ */
2516
+ conditionMode?: DelayConditionMode;
2517
+ }
2518
+ export interface BuiltinVersion {
2519
+ version: string;
2520
+ }
2521
+ export interface DeviceId {
2522
+ deviceId: string;
2523
+ }
2524
+ export interface PluginVersion {
2525
+ version: string;
2526
+ }
2527
+ export interface AutoUpdateEnabled {
2528
+ enabled: boolean;
2529
+ }
2530
+ export interface AutoUpdateAvailable {
2531
+ available: boolean;
2532
+ }
2533
+ /**
2534
+ * Result returned after requesting an immediate native auto-update check.
2535
+ *
2536
+ * @property status - Native trigger state: `queued` when a check was queued,
2537
+ * `already_running` when the native update pipeline is already active, or
2538
+ * `unavailable` on Web or when native auto-update is disabled.
2539
+ * @property queued - Whether a new native update check was queued. This is
2540
+ * `true` only when `status` is `queued`; otherwise it is `false`.
2541
+ */
2542
+ export interface TriggerUpdateCheckResult {
2543
+ /**
2544
+ * Native trigger state: `queued` when a check was queued, `already_running`
2545
+ * when the native update pipeline is already active, or `unavailable` on Web
2546
+ * or when native auto-update is disabled.
2547
+ */
2548
+ status: 'queued' | 'already_running' | 'unavailable';
2549
+ /**
2550
+ * Whether a new native update check was queued. This is `true` only when
2551
+ * `status` is `queued`; otherwise it is `false`.
406
2552
  */
407
- addListener(eventName: "updateFailed", listenerFunc: UpdateFailedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
2553
+ queued: boolean;
2554
+ }
2555
+ /**
2556
+ * Native gesture options that open the shake menu.
2557
+ *
2558
+ * Supported values are `shake` and `threeFingerPinch`.
2559
+ *
2560
+ * @public
2561
+ */
2562
+ export type ShakeMenuGesture = 'shake' | 'threeFingerPinch';
2563
+ export interface SetShakeMenuOptions {
2564
+ enabled: boolean;
2565
+ }
2566
+ export interface ShakeMenuEnabled {
2567
+ enabled: boolean;
408
2568
  /**
409
- * Listen for download fail event in the App, let you know when download has fail finished
2569
+ * The currently configured native gesture used to open the preview/channel menu.
2570
+ * Undefined means consumers should treat the gesture as the default `shake` behavior.
410
2571
  *
411
- * @since 4.0.0
2572
+ * @since 8.48.0
412
2573
  */
413
- addListener(eventName: "downloadFailed", listenerFunc: DownloadFailedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
2574
+ gesture?: ShakeMenuGesture;
2575
+ }
2576
+ export interface SetShakeChannelSelectorOptions {
2577
+ enabled: boolean;
2578
+ }
2579
+ export interface ShakeChannelSelectorEnabled {
2580
+ enabled: boolean;
2581
+ }
2582
+ export interface GetAppIdRes {
2583
+ appId: string;
2584
+ }
2585
+ export interface SetAppIdOptions {
2586
+ appId: string;
2587
+ }
2588
+ /**
2589
+ * Options for {@link CapacitorUpdaterPlugin.getAppUpdateInfo}.
2590
+ *
2591
+ * @since 8.0.0
2592
+ */
2593
+ export interface GetAppUpdateInfoOptions {
414
2594
  /**
415
- * Listen for download fail event in the App, let you know when download has fail finished
2595
+ * Two-letter country code (ISO 3166-1 alpha-2) for the App Store lookup.
416
2596
  *
417
- * @since 4.3.0
2597
+ * This is required on iOS to get accurate App Store information, as app
2598
+ * availability and versions can vary by country.
2599
+ *
2600
+ * Examples: "US", "GB", "DE", "JP", "FR"
2601
+ *
2602
+ * On Android, this option is ignored as the Play Store handles region
2603
+ * detection automatically.
2604
+ *
2605
+ * @since 8.0.0
418
2606
  */
419
- addListener(eventName: "appReloaded", listenerFunc: AppReloadedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
2607
+ country?: string;
2608
+ }
2609
+ /**
2610
+ * Information about app updates available in the App Store or Play Store.
2611
+ *
2612
+ * @since 8.0.0
2613
+ */
2614
+ export interface AppUpdateInfo {
420
2615
  /**
421
- * Get unique ID used to identify device (sent to auto update server)
2616
+ * The currently installed version name (e.g., "1.2.3").
422
2617
  *
423
- * @returns {Promise<{ deviceId: string }>} an Promise with id for this device
424
- * @throws An error if the something went wrong
2618
+ * @since 8.0.0
425
2619
  */
426
- getDeviceId(): Promise<{
427
- deviceId: string;
428
- }>;
2620
+ currentVersionName: string;
429
2621
  /**
430
- * Get the native Capacitor Updater plugin version (sent to auto update server)
2622
+ * The version name available in the store, if an update is available.
2623
+ * May be undefined if no update information is available.
431
2624
  *
432
- * @returns {Promise<{ id: string }>} an Promise with version for this device
433
- * @throws An error if the something went wrong
2625
+ * @since 8.0.0
434
2626
  */
435
- getPluginVersion(): Promise<{
436
- version: string;
437
- }>;
2627
+ availableVersionName?: string;
438
2628
  /**
439
- * Get the state of auto update config. This will return `false` in manual mode.
2629
+ * The currently installed version code (Android) or build number (iOS).
440
2630
  *
441
- * @returns {Promise<{enabled: boolean}>} The status for auto update.
442
- * @throws An error if the something went wrong
2631
+ * @since 8.0.0
443
2632
  */
444
- isAutoUpdateEnabled(): Promise<{
445
- enabled: boolean;
446
- }>;
2633
+ currentVersionCode: string;
447
2634
  /**
448
- * Remove all listeners for this plugin.
2635
+ * The version code available in the store (Android only).
2636
+ * On iOS, this will be the same as `availableVersionName`.
449
2637
  *
450
- * @since 1.0.0
2638
+ * @since 8.0.0
451
2639
  */
452
- removeAllListeners(): Promise<void>;
2640
+ availableVersionCode?: string;
2641
+ /**
2642
+ * The release date of the available version (iOS only).
2643
+ * Format: ISO 8601 date string.
2644
+ *
2645
+ * @since 8.0.0
2646
+ */
2647
+ availableVersionReleaseDate?: string;
2648
+ /**
2649
+ * The current update availability status.
2650
+ *
2651
+ * @since 8.0.0
2652
+ */
2653
+ updateAvailability: AppUpdateAvailability;
2654
+ /**
2655
+ * The priority of the update as set by the developer in Play Console (Android only).
2656
+ * Values range from 0 (default/lowest) to 5 (highest priority).
2657
+ *
2658
+ * Use this to decide whether to show an update prompt or force an update.
2659
+ *
2660
+ * @since 8.0.0
2661
+ */
2662
+ updatePriority?: number;
2663
+ /**
2664
+ * Whether an immediate update is allowed (Android only).
2665
+ *
2666
+ * If `true`, you can call {@link CapacitorUpdaterPlugin.performImmediateUpdate}.
2667
+ *
2668
+ * @since 8.0.0
2669
+ */
2670
+ immediateUpdateAllowed?: boolean;
2671
+ /**
2672
+ * Whether a flexible update is allowed (Android only).
2673
+ *
2674
+ * If `true`, you can call {@link CapacitorUpdaterPlugin.startFlexibleUpdate}.
2675
+ *
2676
+ * @since 8.0.0
2677
+ */
2678
+ flexibleUpdateAllowed?: boolean;
2679
+ /**
2680
+ * Number of days since the update became available (Android only).
2681
+ *
2682
+ * Use this to implement "update nagging" - remind users more frequently
2683
+ * as the update ages.
2684
+ *
2685
+ * @since 8.0.0
2686
+ */
2687
+ clientVersionStalenessDays?: number;
2688
+ /**
2689
+ * The current install status of a flexible update (Android only).
2690
+ *
2691
+ * @since 8.0.0
2692
+ */
2693
+ installStatus?: FlexibleUpdateInstallStatus;
2694
+ /**
2695
+ * The minimum OS version required for the available update (iOS only).
2696
+ *
2697
+ * @since 8.0.0
2698
+ */
2699
+ minimumOsVersion?: string;
2700
+ }
2701
+ /**
2702
+ * Options for {@link CapacitorUpdaterPlugin.openAppStore}.
2703
+ *
2704
+ * @since 8.0.0
2705
+ */
2706
+ export interface OpenAppStoreOptions {
2707
+ /**
2708
+ * The Android package name to open in the Play Store.
2709
+ *
2710
+ * If not specified, uses the current app's package name.
2711
+ * Use this to open a different app's store page.
2712
+ *
2713
+ * Only used on Android.
2714
+ *
2715
+ * @since 8.0.0
2716
+ */
2717
+ packageName?: string;
2718
+ /**
2719
+ * The iOS App Store ID to open.
2720
+ *
2721
+ * If not specified, uses the current app's bundle identifier to look up the app.
2722
+ * Use this to open a different app's store page or when automatic lookup fails.
2723
+ *
2724
+ * Only used on iOS.
2725
+ *
2726
+ * @since 8.0.0
2727
+ */
2728
+ appId?: string;
2729
+ }
2730
+ /**
2731
+ * State information for flexible update progress (Android only).
2732
+ *
2733
+ * @since 8.0.0
2734
+ */
2735
+ export interface FlexibleUpdateState {
2736
+ /**
2737
+ * The current installation status.
2738
+ *
2739
+ * @since 8.0.0
2740
+ */
2741
+ installStatus: FlexibleUpdateInstallStatus;
2742
+ /**
2743
+ * Number of bytes downloaded so far.
2744
+ * Only available during the `DOWNLOADING` status.
2745
+ *
2746
+ * @since 8.0.0
2747
+ */
2748
+ bytesDownloaded?: number;
2749
+ /**
2750
+ * Total number of bytes to download.
2751
+ * Only available during the `DOWNLOADING` status.
2752
+ *
2753
+ * @since 8.0.0
2754
+ */
2755
+ totalBytesToDownload?: number;
2756
+ }
2757
+ /**
2758
+ * Result of an app update operation.
2759
+ *
2760
+ * @since 8.0.0
2761
+ */
2762
+ export interface AppUpdateResult {
2763
+ /**
2764
+ * The result code of the update operation.
2765
+ *
2766
+ * @since 8.0.0
2767
+ */
2768
+ code: AppUpdateResultCode;
2769
+ }
2770
+ /**
2771
+ * Update availability status.
2772
+ *
2773
+ * @since 8.0.0
2774
+ */
2775
+ export declare enum AppUpdateAvailability {
2776
+ /**
2777
+ * Update availability is unknown.
2778
+ * This typically means the check hasn't completed or failed.
2779
+ */
2780
+ UNKNOWN = 0,
2781
+ /**
2782
+ * No update is available.
2783
+ * The installed version is the latest.
2784
+ */
2785
+ UPDATE_NOT_AVAILABLE = 1,
2786
+ /**
2787
+ * An update is available for download.
2788
+ */
2789
+ UPDATE_AVAILABLE = 2,
2790
+ /**
2791
+ * An update is currently being downloaded or installed.
2792
+ */
2793
+ UPDATE_IN_PROGRESS = 3
2794
+ }
2795
+ /**
2796
+ * Installation status for flexible updates (Android only).
2797
+ *
2798
+ * @since 8.0.0
2799
+ */
2800
+ export declare enum FlexibleUpdateInstallStatus {
2801
+ /**
2802
+ * Unknown install status.
2803
+ */
2804
+ UNKNOWN = 0,
2805
+ /**
2806
+ * Download is pending and will start soon.
2807
+ */
2808
+ PENDING = 1,
2809
+ /**
2810
+ * Download is in progress.
2811
+ * Check `bytesDownloaded` and `totalBytesToDownload` for progress.
2812
+ */
2813
+ DOWNLOADING = 2,
2814
+ /**
2815
+ * The update is being installed.
2816
+ */
2817
+ INSTALLING = 3,
2818
+ /**
2819
+ * The update has been installed.
2820
+ * The app needs to be restarted to use the new version.
2821
+ */
2822
+ INSTALLED = 4,
2823
+ /**
2824
+ * The update failed to download or install.
2825
+ */
2826
+ FAILED = 5,
2827
+ /**
2828
+ * The update was canceled by the user.
2829
+ */
2830
+ CANCELED = 6,
2831
+ /**
2832
+ * The update has been downloaded and is ready to install.
2833
+ * Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install.
2834
+ */
2835
+ DOWNLOADED = 11
2836
+ }
2837
+ /**
2838
+ * Result codes for app update operations.
2839
+ *
2840
+ * @since 8.0.0
2841
+ */
2842
+ export declare enum AppUpdateResultCode {
2843
+ /**
2844
+ * The update completed successfully.
2845
+ */
2846
+ OK = 0,
2847
+ /**
2848
+ * The user canceled the update.
2849
+ */
2850
+ CANCELED = 1,
2851
+ /**
2852
+ * The update failed.
2853
+ */
2854
+ FAILED = 2,
2855
+ /**
2856
+ * No update is available.
2857
+ */
2858
+ NOT_AVAILABLE = 3,
2859
+ /**
2860
+ * The requested update type is not allowed.
2861
+ * For example, trying to perform an immediate update when only flexible is allowed.
2862
+ */
2863
+ NOT_ALLOWED = 4,
2864
+ /**
2865
+ * Required information is missing.
2866
+ * This can happen if {@link CapacitorUpdaterPlugin.getAppUpdateInfo} wasn't called first.
2867
+ */
2868
+ INFO_MISSING = 5
453
2869
  }