@capgo/capacitor-updater 9.0.0 → 9.0.1

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