@capgo/capacitor-updater 4.42.0 → 4.43.5

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 (67) hide show
  1. package/CapgoCapacitorUpdater.podspec +7 -5
  2. package/Package.swift +40 -0
  3. package/README.md +1913 -303
  4. package/android/build.gradle +41 -8
  5. package/android/proguard-rules.pro +45 -0
  6. package/android/src/main/AndroidManifest.xml +1 -3
  7. package/android/src/main/java/ee/forgr/capacitor_updater/AppLifecycleObserver.java +88 -0
  8. package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +223 -195
  9. package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +23 -23
  10. package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +13 -0
  11. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +2720 -1242
  12. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +1854 -0
  13. package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +359 -121
  14. package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +28 -0
  15. package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +44 -49
  16. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
  17. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +296 -0
  18. package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +215 -0
  19. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +858 -117
  20. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +156 -0
  21. package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +45 -0
  22. package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +360 -0
  23. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
  24. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +603 -0
  25. package/dist/docs.json +3022 -765
  26. package/dist/esm/definitions.d.ts +1717 -198
  27. package/dist/esm/definitions.js +103 -1
  28. package/dist/esm/definitions.js.map +1 -1
  29. package/dist/esm/history.d.ts +1 -0
  30. package/dist/esm/history.js +283 -0
  31. package/dist/esm/history.js.map +1 -0
  32. package/dist/esm/index.d.ts +3 -2
  33. package/dist/esm/index.js +5 -4
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/web.d.ts +43 -42
  36. package/dist/esm/web.js +122 -37
  37. package/dist/esm/web.js.map +1 -1
  38. package/dist/plugin.cjs.js +512 -37
  39. package/dist/plugin.cjs.js.map +1 -1
  40. package/dist/plugin.js +512 -37
  41. package/dist/plugin.js.map +1 -1
  42. package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +87 -0
  43. package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +55 -0
  44. package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +177 -0
  45. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleStatus.swift +12 -12
  46. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +2020 -0
  47. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +1959 -0
  48. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +313 -0
  49. package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +257 -0
  50. package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
  51. package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +392 -0
  52. package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +310 -0
  53. package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +274 -0
  54. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +441 -0
  55. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +1 -2
  56. package/package.json +49 -41
  57. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +0 -1131
  58. package/ios/Plugin/BundleInfo.swift +0 -113
  59. package/ios/Plugin/CapacitorUpdater.swift +0 -850
  60. package/ios/Plugin/CapacitorUpdaterPlugin.h +0 -10
  61. package/ios/Plugin/CapacitorUpdaterPlugin.m +0 -27
  62. package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -678
  63. package/ios/Plugin/CryptoCipher.swift +0 -240
  64. /package/{LICENCE → LICENSE} +0 -0
  65. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
  66. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
  67. /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,18 @@ 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 API timeout.
19
+ *
20
+ * Only available for Android and iOS.
21
+ *
22
+ * @default 20 // (20 second)
23
+ * @example 10 // (10 second)
24
+ */
25
+ responseTimeout?: number;
17
26
  /**
18
27
  * Configure whether the plugin should use automatically delete failed bundles.
19
28
  *
@@ -43,7 +52,7 @@ declare module "@capacitor/cli" {
43
52
  autoUpdate?: boolean;
44
53
  /**
45
54
  * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.
46
- *
55
+ * 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
56
  * Only available for Android and iOS.
48
57
  *
49
58
  * @default true
@@ -55,27 +64,37 @@ declare module "@capacitor/cli" {
55
64
  *
56
65
  * Only available for Android and iOS.
57
66
  *
58
- * @default https://api.capgo.app/auto_update
67
+ * @default https://plugin.capgo.app/updates
59
68
  * @example https://example.com/api/auto_update
60
69
  */
61
70
  updateUrl?: string;
71
+ /**
72
+ * Configure the URL / endpoint for channel operations.
73
+ *
74
+ * Only available for Android and iOS.
75
+ *
76
+ * @default https://plugin.capgo.app/channel_self
77
+ * @example https://example.com/api/channel
78
+ */
79
+ channelUrl?: string;
62
80
  /**
63
81
  * Configure the URL / endpoint to which update statistics are sent.
64
82
  *
65
83
  * Only available for Android and iOS. Set to "" to disable stats reporting.
66
84
  *
67
- * @default https://api.capgo.app/stats
85
+ * @default https://plugin.capgo.app/stats
68
86
  * @example https://example.com/api/stats
69
87
  */
70
88
  statsUrl?: string;
71
89
  /**
72
- * Configure the private key for end to end live update encryption.
90
+ * Configure the public key for end to end live update encryption Version 2
73
91
  *
74
92
  * Only available for Android and iOS.
75
93
  *
76
94
  * @default undefined
95
+ * @since 6.2.0
77
96
  */
78
- privateKey?: string;
97
+ publicKey?: string;
79
98
  /**
80
99
  * Configure the current version of the app. This will be used for the first update request.
81
100
  * If not set, the plugin will get the version from the native code.
@@ -86,10 +105,1259 @@ declare module "@capacitor/cli" {
86
105
  * @since 4.17.48
87
106
  */
88
107
  version?: string;
108
+ /**
109
+ * Configure when the plugin should direct install updates. Only for autoUpdate mode.
110
+ * Works well for apps less than 10MB and with uploads done using --delta flag.
111
+ * Zip or apps more than 10MB will be relatively slow for users to update.
112
+ * - false: Never do direct updates (use default behavior: download at start, set when backgrounded)
113
+ * - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false
114
+ * - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false
115
+ * - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false
116
+ * - true: (deprecated) Same as "always" for backward compatibility
117
+ *
118
+ * Activate this flag will automatically make the CLI upload delta in CICD envs and will ask for confirmation in local uploads.
119
+ * Only available for Android and iOS.
120
+ *
121
+ * @default false
122
+ * @since 5.1.0
123
+ */
124
+ directUpdate?: boolean | 'atInstall' | 'always' | 'onLaunch';
125
+ /**
126
+ * Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.
127
+ * This removes the need to manually listen for appReady events and call SplashScreen.hide().
128
+ * Only works when directUpdate is set to "atInstall", "always", "onLaunch", or true.
129
+ * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
130
+ * Requires autoUpdate and directUpdate to be enabled.
131
+ *
132
+ * Only available for Android and iOS.
133
+ *
134
+ * @default false
135
+ * @since 7.6.0
136
+ */
137
+ autoSplashscreen?: boolean;
138
+ /**
139
+ * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.
140
+ * Only takes effect when {@link autoSplashscreen} is enabled.
141
+ * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
142
+ *
143
+ * Only available for Android and iOS.
144
+ *
145
+ * @default false
146
+ * @since 7.19.0
147
+ */
148
+ autoSplashscreenLoader?: boolean;
149
+ /**
150
+ * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.
151
+ * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.
152
+ * Set to `0` (zero) to disable the timeout.
153
+ * When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.
154
+ * Requires {@link autoSplashscreen} to be enabled.
155
+ *
156
+ * Only available for Android and iOS.
157
+ *
158
+ * @default 10000 // (10 seconds)
159
+ * @since 7.19.0
160
+ */
161
+ autoSplashscreenTimeout?: number;
162
+ /**
163
+ * Configure the delay period for period update check. the unit is in seconds.
164
+ *
165
+ * Only available for Android and iOS.
166
+ * Cannot be less than 600 seconds (10 minutes).
167
+ *
168
+ * @default 0 (disabled)
169
+ * @example 3600 (1 hour)
170
+ * @example 86400 (24 hours)
171
+ */
172
+ periodCheckDelay?: number;
173
+ /**
174
+ * Configure the CLI to use a local server for testing or self-hosted update server.
175
+ *
176
+ *
177
+ * @default undefined
178
+ * @since 4.17.48
179
+ */
180
+ localS3?: boolean;
181
+ /**
182
+ * Configure the CLI to use a local server for testing or self-hosted update server.
183
+ *
184
+ *
185
+ * @default undefined
186
+ * @since 4.17.48
187
+ */
188
+ localHost?: string;
189
+ /**
190
+ * Configure the CLI to use a local server for testing or self-hosted update server.
191
+ *
192
+ *
193
+ * @default undefined
194
+ * @since 4.17.48
195
+ */
196
+ localWebHost?: string;
197
+ /**
198
+ * Configure the CLI to use a local server for testing or self-hosted update server.
199
+ *
200
+ *
201
+ * @default undefined
202
+ * @since 4.17.48
203
+ */
204
+ localSupa?: string;
205
+ /**
206
+ * Configure the CLI to use a local server for testing.
207
+ *
208
+ *
209
+ * @default undefined
210
+ * @since 4.17.48
211
+ */
212
+ localSupaAnon?: string;
213
+ /**
214
+ * Configure the CLI to use a local api for testing.
215
+ *
216
+ *
217
+ * @default undefined
218
+ * @since 6.3.3
219
+ */
220
+ localApi?: string;
221
+ /**
222
+ * Configure the CLI to use a local file api for testing.
223
+ *
224
+ *
225
+ * @default undefined
226
+ * @since 6.3.3
227
+ */
228
+ localApiFiles?: string;
229
+ /**
230
+ * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.
231
+ *
232
+ *
233
+ * @default false
234
+ * @since 5.4.0
235
+ */
236
+ allowModifyUrl?: boolean;
237
+ /**
238
+ * Allow the plugin to modify the appId dynamically from the JavaScript side.
239
+ *
240
+ *
241
+ * @default false
242
+ * @since 7.14.0
243
+ */
244
+ allowModifyAppId?: boolean;
245
+ /**
246
+ * Allow marking bundles as errored from JavaScript while using manual update flows.
247
+ * When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`.
248
+ *
249
+ * @default false
250
+ * @since 7.20.0
251
+ */
252
+ allowManualBundleError?: boolean;
253
+ /**
254
+ * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.
255
+ *
256
+ * Only available for Android and iOS.
257
+ *
258
+ * @default false (will be true by default in a future major release v8.x.x)
259
+ * @since 7.17.3
260
+ */
261
+ persistCustomId?: boolean;
262
+ /**
263
+ * Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl},
264
+ * {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts.
265
+ *
266
+ * Only available for Android and iOS.
267
+ *
268
+ * @default false
269
+ * @since 7.20.0
270
+ */
271
+ persistModifyUrl?: boolean;
272
+ /**
273
+ * Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel.
274
+ * When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.
275
+ *
276
+ * @default true
277
+ * @since 7.34.0
278
+ */
279
+ allowSetDefaultChannel?: boolean;
280
+ /**
281
+ * Set the default channel for the app in the config. Case sensitive.
282
+ * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.
283
+ * 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
284
+ *
285
+ *
286
+ * @default undefined
287
+ * @since 5.5.0
288
+ */
289
+ defaultChannel?: string;
290
+ /**
291
+ * Configure the app id for the app in the config.
292
+ *
293
+ * @default undefined
294
+ * @since 6.0.0
295
+ */
296
+ appId?: string;
297
+ /**
298
+ * Configure the plugin to keep the URL path after a reload.
299
+ * WARNING: When a reload is triggered, 'window.history' will be cleared.
300
+ *
301
+ * @default false
302
+ * @since 6.8.0
303
+ */
304
+ keepUrlPathAfterReload?: boolean;
305
+ /**
306
+ * 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
307
+ *
308
+ * @default false
309
+ * @since 7.3.0
310
+ */
311
+ disableJSLogging?: boolean;
312
+ /**
313
+ * Enable OS-level logging. When enabled, logs are written to the system log which can be inspected in production builds.
314
+ *
315
+ * - **iOS**: Uses os_log instead of Swift.print, logs accessible via Console.app or Instruments
316
+ * - **Android**: Logs to Logcat (android.util.Log)
317
+ *
318
+ * When set to false, system logging is disabled on both platforms (only JavaScript console logging will occur if enabled).
319
+ *
320
+ * This is useful for debugging production apps (App Store/TestFlight builds on iOS, or production APKs on Android).
321
+ *
322
+ * @default true
323
+ * @since 8.42.0
324
+ */
325
+ osLogging?: boolean;
326
+ /**
327
+ * Enable shake gesture to show update menu for debugging/testing purposes
328
+ *
329
+ * @default false
330
+ * @since 7.5.0
331
+ */
332
+ shakeMenu?: boolean;
333
+ /**
334
+ * Enable the shake gesture to show a channel selector menu for switching between update channels.
335
+ * When enabled AND `shakeMenu` is true, the shake gesture shows a channel selector
336
+ * instead of the default debug menu (Go Home/Reload/Close).
337
+ *
338
+ * After selecting a channel, the app automatically checks for updates and downloads if available.
339
+ * Only works if channels have `allow_self_set` enabled on the backend.
340
+ *
341
+ * Only available for Android and iOS.
342
+ *
343
+ * @default false
344
+ * @since 8.43.0
345
+ */
346
+ allowShakeChannelSelector?: boolean;
89
347
  };
90
348
  }
91
349
  }
92
- export interface noNeedEvent {
350
+ export interface CapacitorUpdaterPlugin {
351
+ /**
352
+ * Notify the native layer that JavaScript initialized successfully.
353
+ *
354
+ * **CRITICAL: You must call this method on every app launch to prevent automatic rollback.**
355
+ *
356
+ * This is a simple notification to confirm that your bundle's JavaScript loaded and executed.
357
+ * The native web server successfully served the bundle files and your JS runtime started.
358
+ * That's all it checks - nothing more complex.
359
+ *
360
+ * **What triggers rollback:**
361
+ * - NOT calling this method within the timeout (default: 10 seconds)
362
+ * - Complete JavaScript failure (bundle won't load at all)
363
+ *
364
+ * **What does NOT trigger rollback:**
365
+ * - Runtime errors after initialization (API failures, crashes, etc.)
366
+ * - Network request failures
367
+ * - Application logic errors
368
+ *
369
+ * **IMPORTANT: Call this BEFORE any network requests.**
370
+ * Don't wait for APIs, data loading, or async operations. Call it as soon as your
371
+ * JavaScript bundle starts executing to confirm the bundle itself is valid.
372
+ *
373
+ * Best practices:
374
+ * - Call immediately in your app entry point (main.js, app component mount, etc.)
375
+ * - Don't put it after network calls or heavy initialization
376
+ * - Don't wrap it in try/catch with conditions
377
+ * - Adjust {@link PluginsConfig.CapacitorUpdater.appReadyTimeout} if you need more time
378
+ *
379
+ * @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.
380
+ */
381
+ notifyAppReady(): Promise<AppReadyResult>;
382
+ /**
383
+ * Set the update URL for the app dynamically at runtime.
384
+ *
385
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.updateUrl} config value.
386
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
387
+ *
388
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
389
+ * Otherwise, the URL will reset to the config value on next app launch.
390
+ *
391
+ * @param options Contains the URL to use for checking for updates.
392
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
393
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
394
+ * @since 5.4.0
395
+ */
396
+ setUpdateUrl(options: UpdateUrl): Promise<void>;
397
+ /**
398
+ * Set the statistics URL for the app dynamically at runtime.
399
+ *
400
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.statsUrl} config value.
401
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
402
+ *
403
+ * Pass an empty string to disable statistics gathering entirely.
404
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
405
+ *
406
+ * @param options Contains the URL to use for sending statistics, or an empty string to disable.
407
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
408
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
409
+ * @since 5.4.0
410
+ */
411
+ setStatsUrl(options: StatsUrl): Promise<void>;
412
+ /**
413
+ * Set the channel URL for the app dynamically at runtime.
414
+ *
415
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.channelUrl} config value.
416
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
417
+ *
418
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
419
+ * Otherwise, the URL will reset to the config value on next app launch.
420
+ *
421
+ * @param options Contains the URL to use for channel operations.
422
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
423
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
424
+ * @since 5.4.0
425
+ */
426
+ setChannelUrl(options: ChannelUrl): Promise<void>;
427
+ /**
428
+ * Download a new bundle from the provided URL for later installation.
429
+ *
430
+ * The downloaded bundle is stored locally but not activated. To use it:
431
+ * - Call {@link next} to set it for installation on next app backgrounding/restart
432
+ * - Call {@link set} to activate it immediately (destroys current JavaScript context)
433
+ *
434
+ * The URL should point to a zip file containing either:
435
+ * - Your app files directly in the zip root, or
436
+ * - A single folder containing all your app files
437
+ *
438
+ * The bundle must include an `index.html` file at the root level.
439
+ *
440
+ * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.
441
+ * For multi-file delta updates, provide the `manifest` array.
442
+ *
443
+ * @example
444
+ * const bundle = await CapacitorUpdater.download({
445
+ * url: `https://example.com/versions/${version}/dist.zip`,
446
+ * version: version
447
+ * });
448
+ * // Bundle is downloaded but not active yet
449
+ * await CapacitorUpdater.next({ id: bundle.id }); // Will activate on next background
450
+ *
451
+ * @param options The {@link DownloadOptions} for downloading a new bundle zip.
452
+ * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the downloaded bundle.
453
+ * @throws {Error} If the download fails or the bundle is invalid.
454
+ */
455
+ download(options: DownloadOptions): Promise<BundleInfo>;
456
+ /**
457
+ * Set the next bundle to be activated when the app backgrounds or restarts.
458
+ *
459
+ * This is the recommended way to apply updates as it doesn't interrupt the user's current session.
460
+ * The bundle will be activated when:
461
+ * - The app is backgrounded (user switches away), or
462
+ * - The app is killed and relaunched, or
463
+ * - {@link reload} is called manually
464
+ *
465
+ * Unlike {@link set}, this method does NOT destroy the current JavaScript context immediately.
466
+ * Your app continues running normally until one of the above events occurs.
467
+ *
468
+ * Use {@link setMultiDelay} to add additional conditions before the update is applied.
469
+ *
470
+ * @param options Contains the ID of the bundle to set as next. Use {@link BundleInfo.id} from a downloaded bundle.
471
+ * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.
472
+ * @throws {Error} When there is no index.html file inside the bundle folder or the bundle doesn't exist.
473
+ */
474
+ next(options: BundleId): Promise<BundleInfo>;
475
+ /**
476
+ * Set the current bundle and immediately reloads the app.
477
+ *
478
+ * **IMPORTANT: This is a terminal operation that destroys the current JavaScript context.**
479
+ *
480
+ * When you call this method:
481
+ * - The entire JavaScript context is immediately destroyed
482
+ * - The app reloads from a different folder with different files
483
+ * - NO code after this call will execute
484
+ * - NO promises will resolve
485
+ * - NO callbacks will fire
486
+ * - Event listeners registered after this call are unreliable and may never fire
487
+ *
488
+ * The reload happens automatically - you don't need to do anything else.
489
+ * If you need to preserve state like the current URL path, use the {@link PluginsConfig.CapacitorUpdater.keepUrlPathAfterReload} config option.
490
+ * For other state preservation needs, save your data before calling this method (e.g., to localStorage).
491
+ *
492
+ * **Do not** try to execute additional logic after calling `set()` - it won't work as expected.
493
+ *
494
+ * @param options A {@link BundleId} object containing the new bundle id to set as current.
495
+ * @returns {Promise<void>} A promise that will never resolve because the JavaScript context is destroyed.
496
+ * @throws {Error} When there is no index.html file inside the bundle folder.
497
+ */
498
+ set(options: BundleId): Promise<void>;
499
+ /**
500
+ * Delete a bundle from local storage to free up disk space.
501
+ *
502
+ * You cannot delete:
503
+ * - The currently active bundle
504
+ * - The `builtin` bundle (the version shipped with your app)
505
+ * - The bundle set as `next` (call {@link next} with a different bundle first)
506
+ *
507
+ * Use {@link list} to get all available bundle IDs.
508
+ *
509
+ * **Note:** The bundle ID is NOT the same as the version name.
510
+ * Use the `id` field from {@link BundleInfo}, not the `version` field.
511
+ *
512
+ * @param options A {@link BundleId} object containing the bundle ID to delete.
513
+ * @returns {Promise<void>} Resolves when the bundle is successfully deleted.
514
+ * @throws {Error} If the bundle is currently in use or doesn't exist.
515
+ */
516
+ delete(options: BundleId): Promise<void>;
517
+ /**
518
+ * Manually mark a bundle as failed/errored in manual update mode.
519
+ *
520
+ * This is useful when you detect that a bundle has critical issues and want to prevent
521
+ * it from being used again. The bundle status will be changed to `error` and the plugin
522
+ * will avoid using this bundle in the future.
523
+ *
524
+ * **Requirements:**
525
+ * - {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} must be set to `true`
526
+ * - Only works in manual update mode (when autoUpdate is disabled)
527
+ *
528
+ * Common use case: After downloading and testing a bundle, you discover it has critical
529
+ * bugs and want to mark it as failed so it won't be retried.
530
+ *
531
+ * @param options A {@link BundleId} object containing the bundle ID to mark as errored.
532
+ * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} with status set to `error`.
533
+ * @throws {Error} When the bundle does not exist or `allowManualBundleError` is false.
534
+ * @since 7.20.0
535
+ */
536
+ setBundleError(options: BundleId): Promise<BundleInfo>;
537
+ /**
538
+ * Get all locally downloaded bundles stored in your app.
539
+ *
540
+ * This returns all bundles that have been downloaded and are available locally, including:
541
+ * - The currently active bundle
542
+ * - The `builtin` bundle (shipped with your app)
543
+ * - Any downloaded bundles waiting to be activated
544
+ * - Failed bundles (with `error` status)
545
+ *
546
+ * Use this to:
547
+ * - Check available disk space by counting bundles
548
+ * - Delete old bundles with {@link delete}
549
+ * - Monitor bundle download status
550
+ *
551
+ * @param options The {@link ListOptions} for customizing the bundle list output.
552
+ * @returns {Promise<BundleListResult>} A promise containing the array of {@link BundleInfo} objects.
553
+ * @throws {Error} If the operation fails.
554
+ */
555
+ list(options?: ListOptions): Promise<BundleListResult>;
556
+ /**
557
+ * Reset the app to a known good bundle.
558
+ *
559
+ * This method helps recover from problematic updates by reverting to either:
560
+ * - The `builtin` bundle (the original version shipped with your app to App Store/Play Store)
561
+ * - The last successfully loaded bundle (most recent bundle that worked correctly)
562
+ *
563
+ * **IMPORTANT: This triggers an immediate app reload, destroying the current JavaScript context.**
564
+ * See {@link set} for details on the implications of this operation.
565
+ *
566
+ * Use cases:
567
+ * - Emergency recovery when an update causes critical issues
568
+ * - Testing rollback functionality
569
+ * - Providing users a "reset to factory" option
570
+ *
571
+ * @param options {@link ResetOptions} to control reset behavior. If `toLastSuccessful` is `false` (or omitted), resets to builtin. If `true`, resets to last successful bundle.
572
+ * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
573
+ * @throws {Error} If the reset operation fails.
574
+ */
575
+ reset(options?: ResetOptions): Promise<void>;
576
+ /**
577
+ * Get information about the currently active bundle.
578
+ *
579
+ * Returns:
580
+ * - `bundle`: The currently active bundle information
581
+ * - `native`: The version of the builtin bundle (the original app version from App/Play Store)
582
+ *
583
+ * If no updates have been applied, `bundle.id` will be `"builtin"`, indicating the app
584
+ * is running the original version shipped with the native app.
585
+ *
586
+ * Use this to:
587
+ * - Display the current version to users
588
+ * - Check if an update is currently active
589
+ * - Compare against available updates
590
+ * - Log the active bundle for debugging
591
+ *
592
+ * @returns {Promise<CurrentBundleResult>} A promise with the current bundle and native version info.
593
+ * @throws {Error} If the operation fails.
594
+ */
595
+ current(): Promise<CurrentBundleResult>;
596
+ /**
597
+ * Manually reload the app to apply a pending update.
598
+ *
599
+ * This triggers the same reload behavior that happens automatically when the app backgrounds.
600
+ * If you've called {@link next} to queue an update, calling `reload()` will apply it immediately.
601
+ *
602
+ * **IMPORTANT: This destroys the current JavaScript context immediately.**
603
+ * See {@link set} for details on the implications of this operation.
604
+ *
605
+ * Common use cases:
606
+ * - Applying an update immediately after download instead of waiting for backgrounding
607
+ * - Providing a "Restart now" button to users after an update is ready
608
+ * - Testing update flows during development
609
+ *
610
+ * If no update is pending (no call to {@link next}), this simply reloads the current bundle.
611
+ *
612
+ * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
613
+ * @throws {Error} If the reload operation fails.
614
+ */
615
+ reload(): Promise<void>;
616
+ /**
617
+ * Configure conditions that must be met before a pending update is applied.
618
+ *
619
+ * After calling {@link next} to queue an update, use this method to control when it gets applied.
620
+ * The update will only be installed after ALL specified conditions are satisfied.
621
+ *
622
+ * Available condition types:
623
+ * - `background`: Wait for the app to be backgrounded. Optionally specify duration in milliseconds.
624
+ * - `kill`: Wait for the app to be killed and relaunched (**Note:** Current behavior triggers update immediately on kill, not on next background. This will be fixed in v8.)
625
+ * - `date`: Wait until a specific date/time (ISO 8601 format)
626
+ * - `nativeVersion`: Wait until the native app is updated to a specific version
627
+ *
628
+ * Condition value formats:
629
+ * - `background`: Number in milliseconds (e.g., `"300000"` for 5 minutes), or omit for immediate
630
+ * - `kill`: No value needed
631
+ * - `date`: ISO 8601 date string (e.g., `"2025-12-31T23:59:59Z"`)
632
+ * - `nativeVersion`: Version string (e.g., `"2.0.0"`)
633
+ *
634
+ * @example
635
+ * // Update after user kills app OR after 5 minutes in background
636
+ * await CapacitorUpdater.setMultiDelay({
637
+ * delayConditions: [
638
+ * { kind: 'kill' },
639
+ * { kind: 'background', value: '300000' }
640
+ * ]
641
+ * });
642
+ *
643
+ * @example
644
+ * // Update after a specific date
645
+ * await CapacitorUpdater.setMultiDelay({
646
+ * delayConditions: [{ kind: 'date', value: '2025-12-31T23:59:59Z' }]
647
+ * });
648
+ *
649
+ * @example
650
+ * // Default behavior: update on next background
651
+ * await CapacitorUpdater.setMultiDelay({
652
+ * delayConditions: [{ kind: 'background' }]
653
+ * });
654
+ *
655
+ * @param options Contains the {@link MultiDelayConditions} array of conditions.
656
+ * @returns {Promise<void>} Resolves when the delay conditions are set.
657
+ * @throws {Error} If the operation fails or conditions are invalid.
658
+ * @since 4.3.0
659
+ */
660
+ setMultiDelay(options: MultiDelayConditions): Promise<void>;
661
+ /**
662
+ * Cancel all delay conditions and apply the pending update immediately.
663
+ *
664
+ * If you've set delay conditions with {@link setMultiDelay}, this method clears them
665
+ * and triggers the pending update to be applied on the next app background or restart.
666
+ *
667
+ * This is useful when:
668
+ * - User manually requests to update now (e.g., clicks "Update now" button)
669
+ * - Your app detects it's a good time to update (e.g., user finished critical task)
670
+ * - You want to override a time-based delay early
671
+ *
672
+ * @returns {Promise<void>} Resolves when the delay conditions are cleared.
673
+ * @throws {Error} If the operation fails.
674
+ * @since 4.0.0
675
+ */
676
+ cancelDelay(): Promise<void>;
677
+ /**
678
+ * Check the update server for the latest available bundle version.
679
+ *
680
+ * This queries your configured update URL (or Capgo backend) to see if a newer bundle
681
+ * is available for download. It does NOT download the bundle automatically.
682
+ *
683
+ * The response includes:
684
+ * - `version`: The latest available version identifier
685
+ * - `url`: Download URL for the bundle (if available)
686
+ * - `breaking`: Whether this update is marked as incompatible (requires native app update)
687
+ * - `message`: Optional message from the server
688
+ * - `manifest`: File list for delta updates (if using multi-file downloads)
689
+ *
690
+ * After receiving the latest version info, you can:
691
+ * 1. Compare it with your current version
692
+ * 2. Download it using {@link download}
693
+ * 3. Apply it using {@link next} or {@link set}
694
+ *
695
+ * **Important: Error handling for "no new version available"**
696
+ *
697
+ * When the device's current version matches the latest version on the server (i.e., the device is already
698
+ * up-to-date), the server returns a 200 response with `error: "no_new_version_available"` and
699
+ * `message: "No new version available"`. **This causes `getLatest()` to throw an error**, even though
700
+ * this is a normal, expected condition.
701
+ *
702
+ * You should catch this specific error to handle it gracefully:
703
+ *
704
+ * ```typescript
705
+ * try {
706
+ * const latest = await CapacitorUpdater.getLatest();
707
+ * // New version is available, proceed with download
708
+ * } catch (error) {
709
+ * if (error.message === 'No new version available') {
710
+ * // Device is already on the latest version - this is normal
711
+ * console.log('Already up to date');
712
+ * } else {
713
+ * // Actual error occurred
714
+ * console.error('Failed to check for updates:', error);
715
+ * }
716
+ * }
717
+ * ```
718
+ *
719
+ * In this scenario, the server:
720
+ * - Logs the request with a "No new version available" message
721
+ * - Sends a "noNew" stat action to track that the device checked for updates but was already current (done on the backend)
722
+ *
723
+ * @param options Optional {@link GetLatestOptions} to specify which channel to check.
724
+ * @returns {Promise<LatestVersion>} Information about the latest available bundle version.
725
+ * @throws {Error} Always throws when no new version is available (`error: "no_new_version_available"`), or when the request fails.
726
+ * @since 4.0.0
727
+ */
728
+ getLatest(options?: GetLatestOptions): Promise<LatestVersion>;
729
+ /**
730
+ * Assign this device to a specific update channel at runtime.
731
+ *
732
+ * Channels allow you to distribute different bundle versions to different groups of users
733
+ * (e.g., "production", "beta", "staging"). This method switches the device to a new channel.
734
+ *
735
+ * **Requirements:**
736
+ * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)
737
+ * - The backend may accept or reject the request based on channel settings
738
+ *
739
+ * **When to use:**
740
+ * - After the app is ready and the user has interacted (e.g., opted into beta program)
741
+ * - To implement in-app channel switching (beta toggle, tester access, etc.)
742
+ * - For user-driven channel changes
743
+ *
744
+ * **When NOT to use:**
745
+ * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead
746
+ * - Before user interaction
747
+ *
748
+ * **Important: Listen for the `channelPrivate` event**
749
+ *
750
+ * When a user attempts to set a channel that doesn't allow device self-assignment, the method will
751
+ * throw an error AND fire a {@link addListener}('channelPrivate') event. You should listen to this event
752
+ * to provide appropriate feedback to users:
753
+ *
754
+ * ```typescript
755
+ * CapacitorUpdater.addListener('channelPrivate', (data) => {
756
+ * console.warn(`Cannot access channel "${data.channel}": ${data.message}`);
757
+ * // Show user-friendly message
758
+ * });
759
+ * ```
760
+ *
761
+ * This sends a request to the Capgo backend linking your device ID to the specified channel.
762
+ *
763
+ * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.
764
+ * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.
765
+ * @throws {Error} If the channel doesn't exist or doesn't allow self-assignment.
766
+ * @since 4.7.0
767
+ */
768
+ setChannel(options: SetChannelOptions): Promise<ChannelRes>;
769
+ /**
770
+ * Remove the device's channel assignment and return to the default channel.
771
+ *
772
+ * This unlinks the device from any specifically assigned channel, causing it to fall back to:
773
+ * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or
774
+ * - Your backend's default channel for this app
775
+ *
776
+ * Use this when:
777
+ * - Users opt out of beta/testing programs
778
+ * - You want to reset a device to standard update distribution
779
+ * - Testing channel switching behavior
780
+ *
781
+ * @param options {@link UnsetChannelOptions} containing optional auto-update trigger.
782
+ * @returns {Promise<void>} Resolves when the channel is successfully unset.
783
+ * @throws {Error} If the operation fails.
784
+ * @since 4.7.0
785
+ */
786
+ unsetChannel(options: UnsetChannelOptions): Promise<void>;
787
+ /**
788
+ * Get the current channel assigned to this device.
789
+ *
790
+ * Returns information about:
791
+ * - `channel`: The currently assigned channel name (if any)
792
+ * - `allowSet`: Whether the channel allows self-assignment
793
+ * - `status`: Operation status
794
+ * - `error`/`message`: Additional information (if applicable)
795
+ *
796
+ * Use this to:
797
+ * - Display current channel to users (e.g., "You're on the Beta channel")
798
+ * - Check if a device is on a specific channel before showing features
799
+ * - Verify channel assignment after calling {@link setChannel}
800
+ *
801
+ * @returns {Promise<GetChannelRes>} The current channel information.
802
+ * @throws {Error} If the operation fails.
803
+ * @since 4.8.0
804
+ */
805
+ getChannel(): Promise<GetChannelRes>;
806
+ /**
807
+ * Get a list of all channels available for this device to self-assign to.
808
+ *
809
+ * Only returns channels where `allow_self_set` is `true`. These are channels that
810
+ * users can switch to using {@link setChannel} without backend administrator intervention.
811
+ *
812
+ * Each channel includes:
813
+ * - `id`: Unique channel identifier
814
+ * - `name`: Human-readable channel name
815
+ * - `public`: Whether the channel is publicly visible
816
+ * - `allow_self_set`: Always `true` in results (filtered to only self-assignable channels)
817
+ *
818
+ * Use this to:
819
+ * - Build a channel selector UI for users (e.g., "Join Beta" button)
820
+ * - Show available testing/preview channels
821
+ * - Implement channel discovery features
822
+ *
823
+ * @returns {Promise<ListChannelsResult>} List of channels the device can self-assign to.
824
+ * @throws {Error} If the operation fails or the request to the backend fails.
825
+ * @since 7.5.0
826
+ */
827
+ listChannels(): Promise<ListChannelsResult>;
828
+ /**
829
+ * Set a custom identifier for this device.
830
+ *
831
+ * This allows you to identify devices by your own custom ID (user ID, account ID, etc.)
832
+ * instead of or in addition to the device's unique hardware ID. The custom ID is sent
833
+ * to your update server and can be used for:
834
+ * - Targeting specific users for updates
835
+ * - Analytics and user tracking
836
+ * - Debugging and support (correlating devices with users)
837
+ * - A/B testing or feature flagging
838
+ *
839
+ * **Persistence:**
840
+ * - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true`, the ID persists across app restarts
841
+ * - When `false`, the ID is only kept for the current session
842
+ *
843
+ * **Clearing the custom ID:**
844
+ * - Pass an empty string `""` to remove any stored custom ID
845
+ *
846
+ * @param options The {@link SetCustomIdOptions} containing the custom identifier string.
847
+ * @returns {Promise<void>} Resolves immediately (synchronous operation).
848
+ * @throws {Error} If the operation fails.
849
+ * @since 4.9.0
850
+ */
851
+ setCustomId(options: SetCustomIdOptions): Promise<void>;
852
+ /**
853
+ * Get the builtin bundle version (the original version shipped with your native app).
854
+ *
855
+ * This returns the version of the bundle that was included when the app was installed
856
+ * from the App Store or Play Store. This is NOT the currently active bundle version -
857
+ * use {@link current} for that.
858
+ *
859
+ * Returns:
860
+ * - The {@link PluginsConfig.CapacitorUpdater.version} config value if set, or
861
+ * - The native app version from platform configs (package.json, Info.plist, build.gradle)
862
+ *
863
+ * Use this to:
864
+ * - Display the "factory" version to users
865
+ * - Compare against downloaded bundle versions
866
+ * - Determine if any updates have been applied
867
+ * - Debugging version mismatches
868
+ *
869
+ * @returns {Promise<BuiltinVersion>} The builtin bundle version string.
870
+ * @since 5.2.0
871
+ */
872
+ getBuiltinVersion(): Promise<BuiltinVersion>;
873
+ /**
874
+ * Get the unique, privacy-friendly identifier for this device.
875
+ *
876
+ * This ID is used to identify the device when communicating with update servers.
877
+ * It's automatically generated and stored securely by the plugin.
878
+ *
879
+ * **Privacy & Security characteristics:**
880
+ * - Generated as a UUID (not based on hardware identifiers)
881
+ * - Stored securely in platform-specific secure storage
882
+ * - Android: Android Keystore (persists across app reinstalls on API 23+)
883
+ * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`
884
+ * - Not synced to cloud (iOS)
885
+ * - Follows Apple and Google privacy best practices
886
+ * - Users can clear it via system settings (Android) or keychain access (iOS)
887
+ *
888
+ * **Persistence:**
889
+ * The device ID persists across app reinstalls to maintain consistent device identity
890
+ * for update tracking and analytics.
891
+ *
892
+ * Use this to:
893
+ * - Debug update delivery issues (check what ID the server sees)
894
+ * - Implement device-specific features
895
+ * - Correlate server logs with specific devices
896
+ *
897
+ * @returns {Promise<DeviceId>} The unique device identifier string.
898
+ * @throws {Error} If the operation fails.
899
+ */
900
+ getDeviceId(): Promise<DeviceId>;
901
+ /**
902
+ * Get the version of the Capacitor Updater plugin installed in your app.
903
+ *
904
+ * This returns the version of the native plugin code (Android/iOS), which is sent
905
+ * to the update server with each request. This is NOT your app version or bundle version.
906
+ *
907
+ * Use this to:
908
+ * - Debug plugin-specific issues (when reporting bugs)
909
+ * - Verify plugin installation and version
910
+ * - Check compatibility with backend features
911
+ * - Display in debug/about screens
912
+ *
913
+ * @returns {Promise<PluginVersion>} The Capacitor Updater plugin version string.
914
+ * @throws {Error} If the operation fails.
915
+ */
916
+ getPluginVersion(): Promise<PluginVersion>;
917
+ /**
918
+ * Check if automatic updates are currently enabled.
919
+ *
920
+ * Returns `true` if {@link PluginsConfig.CapacitorUpdater.autoUpdate} is enabled,
921
+ * meaning the plugin will automatically check for, download, and apply updates.
922
+ *
923
+ * Returns `false` if in manual mode, where you control the update flow using
924
+ * {@link getLatest}, {@link download}, {@link next}, and {@link set}.
925
+ *
926
+ * Use this to:
927
+ * - Determine which update flow your app is using
928
+ * - Show/hide manual update UI based on mode
929
+ * - Debug update behavior
930
+ *
931
+ * @returns {Promise<AutoUpdateEnabled>} `true` if auto-update is enabled, `false` if in manual mode.
932
+ * @throws {Error} If the operation fails.
933
+ */
934
+ isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;
935
+ /**
936
+ * Remove all event listeners registered for this plugin.
937
+ *
938
+ * This unregisters all listeners added via {@link addListener} for all event types:
939
+ * - `download`
940
+ * - `noNeedUpdate`
941
+ * - `updateAvailable`
942
+ * - `downloadComplete`
943
+ * - `downloadFailed`
944
+ * - `breakingAvailable` / `majorAvailable`
945
+ * - `updateFailed`
946
+ * - `appReloaded`
947
+ * - `appReady`
948
+ *
949
+ * Use this during cleanup (e.g., when unmounting components or closing screens)
950
+ * to prevent memory leaks from lingering event listeners.
951
+ *
952
+ * @returns {Promise<void>} Resolves when all listeners are removed.
953
+ * @since 1.0.0
954
+ */
955
+ removeAllListeners(): Promise<void>;
956
+ /**
957
+ * Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.
958
+ * This will return you all download percent during the download
959
+ *
960
+ * @since 2.0.11
961
+ */
962
+ addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;
963
+ /**
964
+ * Listen for no need to update event, useful when you want force check every time the app is launched
965
+ *
966
+ * @since 4.0.0
967
+ */
968
+ addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;
969
+ /**
970
+ * Listen for available update event, useful when you want to force check every time the app is launched
971
+ *
972
+ * @since 4.0.0
973
+ */
974
+ addListener(eventName: 'updateAvailable', listenerFunc: (state: UpdateAvailableEvent) => void): Promise<PluginListenerHandle>;
975
+ /**
976
+ * Listen for downloadComplete events.
977
+ *
978
+ * @since 4.0.0
979
+ */
980
+ addListener(eventName: 'downloadComplete', listenerFunc: (state: DownloadCompleteEvent) => void): Promise<PluginListenerHandle>;
981
+ /**
982
+ * Listen for breaking update events when the backend flags an update as incompatible with the current app.
983
+ * Emits the same payload as the legacy `majorAvailable` listener.
984
+ *
985
+ * @since 7.22.0
986
+ */
987
+ addListener(eventName: 'breakingAvailable', listenerFunc: (state: BreakingAvailableEvent) => void): Promise<PluginListenerHandle>;
988
+ /**
989
+ * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
990
+ *
991
+ * @deprecated Deprecated alias for {@link addListener} with `breakingAvailable`. Emits the same payload. will be removed in v8
992
+ * @since 2.3.0
993
+ */
994
+ addListener(eventName: 'majorAvailable', listenerFunc: (state: MajorAvailableEvent) => void): Promise<PluginListenerHandle>;
995
+ /**
996
+ * Listen for update fail event in the App, let you know when update has fail to install at next app start
997
+ *
998
+ * @since 2.3.0
999
+ */
1000
+ addListener(eventName: 'updateFailed', listenerFunc: (state: UpdateFailedEvent) => void): Promise<PluginListenerHandle>;
1001
+ /**
1002
+ * Listen for download fail event in the App, let you know when a bundle download has failed
1003
+ *
1004
+ * @since 4.0.0
1005
+ */
1006
+ addListener(eventName: 'downloadFailed', listenerFunc: (state: DownloadFailedEvent) => void): Promise<PluginListenerHandle>;
1007
+ /**
1008
+ * Listen for reload event in the App, let you know when reload has happened
1009
+ *
1010
+ * @since 4.3.0
1011
+ */
1012
+ addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;
1013
+ /**
1014
+ * Listen for app ready event in the App, let you know when app is ready to use, this event is retain till consumed.
1015
+ *
1016
+ * @since 5.1.0
1017
+ */
1018
+ addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;
1019
+ /**
1020
+ * Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.
1021
+ *
1022
+ * This event is useful for:
1023
+ * - Informing users they don't have permission to switch to a specific channel
1024
+ * - Implementing custom error handling for channel restrictions
1025
+ * - Logging unauthorized channel access attempts
1026
+ *
1027
+ * @since 7.34.0
1028
+ */
1029
+ addListener(eventName: 'channelPrivate', listenerFunc: (state: ChannelPrivateEvent) => void): Promise<PluginListenerHandle>;
1030
+ /**
1031
+ * Listen for flexible update state changes on Android.
1032
+ *
1033
+ * This event fires during the flexible update download process, providing:
1034
+ * - Download progress (bytes downloaded / total bytes)
1035
+ * - Installation status changes
1036
+ *
1037
+ * **Install status values:**
1038
+ * - `UNKNOWN` (0): Unknown status
1039
+ * - `PENDING` (1): Download pending
1040
+ * - `DOWNLOADING` (2): Download in progress
1041
+ * - `INSTALLING` (3): Installing the update
1042
+ * - `INSTALLED` (4): Update installed (app restart needed)
1043
+ * - `FAILED` (5): Update failed
1044
+ * - `CANCELED` (6): Update was canceled
1045
+ * - `DOWNLOADED` (11): Download complete, ready to install
1046
+ *
1047
+ * When status is `DOWNLOADED`, you should prompt the user and call
1048
+ * {@link completeFlexibleUpdate} to finish the installation.
1049
+ *
1050
+ * @since 8.0.0
1051
+ */
1052
+ addListener(eventName: 'onFlexibleUpdateStateChange', listenerFunc: (state: FlexibleUpdateState) => void): Promise<PluginListenerHandle>;
1053
+ /**
1054
+ * Check if the auto-update feature is available (not disabled by custom server configuration).
1055
+ *
1056
+ * Returns `false` when a custom `updateUrl` is configured, as this typically indicates
1057
+ * you're using a self-hosted update server that may not support all auto-update features.
1058
+ *
1059
+ * Returns `true` when using the default Capgo backend or when the feature is available.
1060
+ *
1061
+ * This is different from {@link isAutoUpdateEnabled}:
1062
+ * - `isAutoUpdateEnabled()`: Checks if auto-update MODE is turned on/off
1063
+ * - `isAutoUpdateAvailable()`: Checks if auto-update is SUPPORTED with your current configuration
1064
+ *
1065
+ * @returns {Promise<AutoUpdateAvailable>} `false` when custom updateUrl is set, `true` otherwise.
1066
+ * @throws {Error} If the operation fails.
1067
+ */
1068
+ isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;
1069
+ /**
1070
+ * Get information about the bundle queued to be activated on next reload.
1071
+ *
1072
+ * Returns:
1073
+ * - {@link BundleInfo} object if a bundle has been queued via {@link next}
1074
+ * - `null` if no update is pending
1075
+ *
1076
+ * This is useful to:
1077
+ * - Check if an update is waiting to be applied
1078
+ * - Display "Update pending" status to users
1079
+ * - Show version info of the queued update
1080
+ * - Decide whether to show a "Restart to update" prompt
1081
+ *
1082
+ * The queued bundle will be activated when:
1083
+ * - The app is backgrounded (default behavior)
1084
+ * - The app is killed and restarted
1085
+ * - {@link reload} is called manually
1086
+ * - Delay conditions set by {@link setMultiDelay} are met
1087
+ *
1088
+ * @returns {Promise<BundleInfo | null>} The pending bundle info, or `null` if none is queued.
1089
+ * @throws {Error} If the operation fails.
1090
+ * @since 6.8.0
1091
+ */
1092
+ getNextBundle(): Promise<BundleInfo | null>;
1093
+ /**
1094
+ * Retrieve information about the most recent bundle that failed to load.
1095
+ *
1096
+ * When a bundle fails to load (e.g., JavaScript errors prevent initialization, missing files),
1097
+ * the plugin automatically rolls back and stores information about the failure. This method
1098
+ * retrieves that failure information.
1099
+ *
1100
+ * **IMPORTANT: The stored value is cleared after being retrieved once.**
1101
+ * Calling this method multiple times will only return the failure info on the first call,
1102
+ * then `null` on subsequent calls until another failure occurs.
1103
+ *
1104
+ * Returns:
1105
+ * - {@link UpdateFailedEvent} with bundle info if a failure was recorded
1106
+ * - `null` if no failure has occurred or if it was already retrieved
1107
+ *
1108
+ * Use this to:
1109
+ * - Show users why an update failed
1110
+ * - Log failure information for debugging
1111
+ * - Implement custom error handling/reporting
1112
+ * - Display rollback notifications
1113
+ *
1114
+ * @returns {Promise<UpdateFailedEvent | null>} The failed update info (cleared after first retrieval), or `null`.
1115
+ * @throws {Error} If the operation fails.
1116
+ * @since 7.22.0
1117
+ */
1118
+ getFailedUpdate(): Promise<UpdateFailedEvent | null>;
1119
+ /**
1120
+ * Enable or disable the shake gesture menu for debugging and testing.
1121
+ *
1122
+ * When enabled, users can shake their device to open a debug menu that shows:
1123
+ * - Current bundle information
1124
+ * - Available bundles
1125
+ * - Options to switch bundles manually
1126
+ * - Update status
1127
+ *
1128
+ * This is useful during development and testing to:
1129
+ * - Quickly test different bundle versions
1130
+ * - Debug update flows
1131
+ * - Switch between production and test bundles
1132
+ * - Verify bundle installations
1133
+ *
1134
+ * **Important:** Disable this in production builds or only enable for internal testers.
1135
+ *
1136
+ * Can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1137
+ *
1138
+ * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.
1139
+ * @returns {Promise<void>} Resolves when the setting is applied.
1140
+ * @throws {Error} If the operation fails.
1141
+ * @since 7.5.0
1142
+ */
1143
+ setShakeMenu(options: SetShakeMenuOptions): Promise<void>;
1144
+ /**
1145
+ * Check if the shake gesture debug menu is currently enabled.
1146
+ *
1147
+ * Returns the current state of the shake menu feature that can be toggled via
1148
+ * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1149
+ *
1150
+ * Use this to:
1151
+ * - Check if debug features are enabled
1152
+ * - Show/hide debug settings UI
1153
+ * - Verify configuration during testing
1154
+ *
1155
+ * @returns {Promise<ShakeMenuEnabled>} Object with `enabled: true` or `enabled: false`.
1156
+ * @throws {Error} If the operation fails.
1157
+ * @since 7.5.0
1158
+ */
1159
+ isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;
1160
+ /**
1161
+ * Enable or disable the shake channel selector at runtime.
1162
+ *
1163
+ * When enabled AND shakeMenu is true, shaking the device shows a channel
1164
+ * selector instead of the debug menu. This allows users to switch between
1165
+ * update channels by shaking their device.
1166
+ *
1167
+ * After selecting a channel, the app automatically checks for updates
1168
+ * and downloads if available.
1169
+ *
1170
+ * Can also be configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
1171
+ *
1172
+ * @param options {@link SetShakeChannelSelectorOptions} with `enabled: true` to enable or `enabled: false` to disable.
1173
+ * @returns {Promise<void>} Resolves when the setting is applied.
1174
+ * @throws {Error} If the operation fails.
1175
+ * @since 8.43.0
1176
+ */
1177
+ setShakeChannelSelector(options: SetShakeChannelSelectorOptions): Promise<void>;
1178
+ /**
1179
+ * Check if the shake channel selector is currently enabled.
1180
+ *
1181
+ * Returns the current state of the shake channel selector feature that can be toggled via
1182
+ * {@link setShakeChannelSelector} or configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
1183
+ *
1184
+ * @returns {Promise<ShakeChannelSelectorEnabled>} Object with `enabled: true` or `enabled: false`.
1185
+ * @throws {Error} If the operation fails.
1186
+ * @since 8.43.0
1187
+ */
1188
+ isShakeChannelSelectorEnabled(): Promise<ShakeChannelSelectorEnabled>;
1189
+ /**
1190
+ * Get the currently configured App ID used for update server communication.
1191
+ *
1192
+ * Returns the App ID that identifies this app to the update server. This can be:
1193
+ * - The value set via {@link setAppId}, or
1194
+ * - The {@link PluginsConfig.CapacitorUpdater.appId} config value, or
1195
+ * - The default app identifier from your native app configuration
1196
+ *
1197
+ * Use this to:
1198
+ * - Verify which App ID is being used for updates
1199
+ * - Debug update delivery issues
1200
+ * - Display app configuration in debug screens
1201
+ * - Confirm App ID after calling {@link setAppId}
1202
+ *
1203
+ * @returns {Promise<GetAppIdRes>} Object containing the current `appId` string.
1204
+ * @throws {Error} If the operation fails.
1205
+ * @since 7.14.0
1206
+ */
1207
+ getAppId(): Promise<GetAppIdRes>;
1208
+ /**
1209
+ * Dynamically change the App ID used for update server communication.
1210
+ *
1211
+ * This overrides the App ID used to identify your app to the update server, allowing you
1212
+ * to switch between different app configurations at runtime (e.g., production vs staging
1213
+ * app IDs, or multi-tenant configurations).
1214
+ *
1215
+ * **Requirements:**
1216
+ * - {@link PluginsConfig.CapacitorUpdater.allowModifyAppId} must be set to `true`
1217
+ *
1218
+ * **Important considerations:**
1219
+ * - Changing the App ID will affect which updates this device receives
1220
+ * - The new App ID must exist on your update server
1221
+ * - This is primarily for advanced use cases (multi-tenancy, environment switching)
1222
+ * - Most apps should use the config-based {@link PluginsConfig.CapacitorUpdater.appId} instead
1223
+ *
1224
+ * @param options {@link SetAppIdOptions} containing the new App ID string.
1225
+ * @returns {Promise<void>} Resolves when the App ID is successfully changed.
1226
+ * @throws {Error} If `allowModifyAppId` is false or the operation fails.
1227
+ * @since 7.14.0
1228
+ */
1229
+ setAppId(options: SetAppIdOptions): Promise<void>;
1230
+ /**
1231
+ * Get information about the app's availability in the App Store or Play Store.
1232
+ *
1233
+ * This method checks the native app stores to see if a newer version of the app
1234
+ * is available for download. This is different from Capgo's OTA updates - this
1235
+ * checks for native app updates that require going through the app stores.
1236
+ *
1237
+ * **Platform differences:**
1238
+ * - **Android**: Uses Play Store's In-App Updates API for accurate update information
1239
+ * - **iOS**: Queries the App Store lookup API (requires country code for accurate results)
1240
+ *
1241
+ * **Returns information about:**
1242
+ * - Current installed version
1243
+ * - Available version in the store (if any)
1244
+ * - Whether an update is available
1245
+ * - Update priority (Android only)
1246
+ * - Whether immediate/flexible updates are allowed (Android only)
1247
+ *
1248
+ * Use this to:
1249
+ * - Check if users need to update from the app store
1250
+ * - Show "Update Available" prompts for native updates
1251
+ * - Implement version gating (require minimum native version)
1252
+ * - Combine with Capgo OTA updates for a complete update strategy
1253
+ *
1254
+ * @param options Optional {@link GetAppUpdateInfoOptions} with country code for iOS.
1255
+ * @returns {Promise<AppUpdateInfo>} Information about the current and available app versions.
1256
+ * @throws {Error} If the operation fails or store information is unavailable.
1257
+ * @since 8.0.0
1258
+ */
1259
+ getAppUpdateInfo(options?: GetAppUpdateInfoOptions): Promise<AppUpdateInfo>;
1260
+ /**
1261
+ * Open the app's page in the App Store or Play Store.
1262
+ *
1263
+ * This navigates the user to your app's store listing where they can manually
1264
+ * update the app. Use this as a fallback when in-app updates are not available
1265
+ * or when the user needs to update on iOS.
1266
+ *
1267
+ * **Platform behavior:**
1268
+ * - **Android**: Opens Play Store to the app's page
1269
+ * - **iOS**: Opens App Store to the app's page
1270
+ *
1271
+ * **Customization options:**
1272
+ * - `appId`: Specify a custom App Store ID (iOS) - useful for opening a different app's page
1273
+ * - `packageName`: Specify a custom package name (Android) - useful for opening a different app's page
1274
+ *
1275
+ * @param options Optional {@link OpenAppStoreOptions} to customize which app's store page to open.
1276
+ * @returns {Promise<void>} Resolves when the store is opened.
1277
+ * @throws {Error} If the store cannot be opened.
1278
+ * @since 8.0.0
1279
+ */
1280
+ openAppStore(options?: OpenAppStoreOptions): Promise<void>;
1281
+ /**
1282
+ * Perform an immediate in-app update on Android.
1283
+ *
1284
+ * This triggers Google Play's immediate update flow, which:
1285
+ * 1. Shows a full-screen update UI
1286
+ * 2. Downloads and installs the update
1287
+ * 3. Restarts the app automatically
1288
+ *
1289
+ * The user cannot continue using the app until the update is complete.
1290
+ * This is ideal for critical updates that must be installed immediately.
1291
+ *
1292
+ * **Requirements:**
1293
+ * - Android only (throws error on iOS)
1294
+ * - An update must be available (check with {@link getAppUpdateInfo} first)
1295
+ * - The update must allow immediate updates (`immediateUpdateAllowed: true`)
1296
+ *
1297
+ * **User experience:**
1298
+ * - Full-screen blocking UI
1299
+ * - Progress shown during download
1300
+ * - App automatically restarts after installation
1301
+ *
1302
+ * @returns {Promise<AppUpdateResult>} Result indicating success, cancellation, or failure.
1303
+ * @throws {Error} If not on Android, no update is available, or immediate updates not allowed.
1304
+ * @since 8.0.0
1305
+ */
1306
+ performImmediateUpdate(): Promise<AppUpdateResult>;
1307
+ /**
1308
+ * Start a flexible in-app update on Android.
1309
+ *
1310
+ * This triggers Google Play's flexible update flow, which:
1311
+ * 1. Downloads the update in the background
1312
+ * 2. Allows the user to continue using the app
1313
+ * 3. Notifies when download is complete
1314
+ * 4. Requires calling {@link completeFlexibleUpdate} to install
1315
+ *
1316
+ * Monitor the download progress using the `onFlexibleUpdateStateChange` listener.
1317
+ *
1318
+ * **Requirements:**
1319
+ * - Android only (throws error on iOS)
1320
+ * - An update must be available (check with {@link getAppUpdateInfo} first)
1321
+ * - The update must allow flexible updates (`flexibleUpdateAllowed: true`)
1322
+ *
1323
+ * **Typical flow:**
1324
+ * 1. Call `startFlexibleUpdate()` to begin download
1325
+ * 2. Listen to `onFlexibleUpdateStateChange` for progress
1326
+ * 3. When status is `DOWNLOADED`, prompt user to restart
1327
+ * 4. Call `completeFlexibleUpdate()` to install and restart
1328
+ *
1329
+ * @returns {Promise<AppUpdateResult>} Result indicating the update was started, cancelled, or failed.
1330
+ * @throws {Error} If not on Android, no update is available, or flexible updates not allowed.
1331
+ * @since 8.0.0
1332
+ */
1333
+ startFlexibleUpdate(): Promise<AppUpdateResult>;
1334
+ /**
1335
+ * Complete a flexible in-app update on Android.
1336
+ *
1337
+ * After a flexible update has been downloaded (status `DOWNLOADED` in
1338
+ * `onFlexibleUpdateStateChange`), call this method to install the update
1339
+ * and restart the app.
1340
+ *
1341
+ * **Important:** This will immediately restart the app. Make sure to:
1342
+ * - Save any user data before calling
1343
+ * - Prompt the user before restarting
1344
+ * - Only call when the download status is `DOWNLOADED`
1345
+ *
1346
+ * @returns {Promise<void>} Resolves when the update installation begins (app will restart).
1347
+ * @throws {Error} If not on Android or no downloaded update is pending.
1348
+ * @since 8.0.0
1349
+ */
1350
+ completeFlexibleUpdate(): Promise<void>;
1351
+ }
1352
+ /**
1353
+ * pending: The bundle is pending to be **SET** as the next bundle.
1354
+ * downloading: The bundle is being downloaded.
1355
+ * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.
1356
+ * error: The bundle has failed to download.
1357
+ */
1358
+ export type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';
1359
+ export type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';
1360
+ export interface NoNeedEvent {
93
1361
  /**
94
1362
  * Current status of download, between 0 and 100.
95
1363
  *
@@ -97,7 +1365,7 @@ export interface noNeedEvent {
97
1365
  */
98
1366
  bundle: BundleInfo;
99
1367
  }
100
- export interface updateAvailableEvent {
1368
+ export interface UpdateAvailableEvent {
101
1369
  /**
102
1370
  * Current status of download, between 0 and 100.
103
1371
  *
@@ -105,28 +1373,62 @@ export interface updateAvailableEvent {
105
1373
  */
106
1374
  bundle: BundleInfo;
107
1375
  }
108
- export interface channelRes {
1376
+ export interface ChannelRes {
109
1377
  /**
110
1378
  * Current status of set channel
111
1379
  *
112
1380
  * @since 4.7.0
113
1381
  */
114
1382
  status: string;
115
- error?: any;
116
- message?: any;
1383
+ error?: string;
1384
+ message?: string;
117
1385
  }
118
- export interface getChannelRes {
1386
+ export interface GetChannelRes {
119
1387
  /**
120
1388
  * Current status of get channel
121
1389
  *
122
1390
  * @since 4.8.0
123
1391
  */
124
1392
  channel?: string;
125
- error?: any;
126
- message?: any;
1393
+ error?: string;
1394
+ message?: string;
127
1395
  status?: string;
128
1396
  allowSet?: boolean;
129
1397
  }
1398
+ export interface ChannelInfo {
1399
+ /**
1400
+ * The channel ID
1401
+ *
1402
+ * @since 7.5.0
1403
+ */
1404
+ id: string;
1405
+ /**
1406
+ * The channel name
1407
+ *
1408
+ * @since 7.5.0
1409
+ */
1410
+ name: string;
1411
+ /**
1412
+ * Whether this is a public channel
1413
+ *
1414
+ * @since 7.5.0
1415
+ */
1416
+ public: boolean;
1417
+ /**
1418
+ * Whether devices can self-assign to this channel
1419
+ *
1420
+ * @since 7.5.0
1421
+ */
1422
+ allow_self_set: boolean;
1423
+ }
1424
+ export interface ListChannelsResult {
1425
+ /**
1426
+ * List of available channels
1427
+ *
1428
+ * @since 7.5.0
1429
+ */
1430
+ channels: ChannelInfo[];
1431
+ }
130
1432
  export interface DownloadEvent {
131
1433
  /**
132
1434
  * Current status of download, between 0 and 100.
@@ -138,12 +1440,19 @@ export interface DownloadEvent {
138
1440
  }
139
1441
  export interface MajorAvailableEvent {
140
1442
  /**
141
- * Emit when a new major bundle is available.
1443
+ * Emit when a breaking update is available.
142
1444
  *
1445
+ * @deprecated Deprecated alias for {@link BreakingAvailableEvent}. Receives the same payload.
143
1446
  * @since 4.0.0
144
1447
  */
145
1448
  version: string;
146
1449
  }
1450
+ /**
1451
+ * Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvailable`.
1452
+ *
1453
+ * @since 7.22.0
1454
+ */
1455
+ export type BreakingAvailableEvent = MajorAvailableEvent;
147
1456
  export interface DownloadFailedEvent {
148
1457
  /**
149
1458
  * Emit when a download fail.
@@ -168,19 +1477,86 @@ export interface UpdateFailedEvent {
168
1477
  */
169
1478
  bundle: BundleInfo;
170
1479
  }
171
- export interface latestVersion {
1480
+ export interface AppReadyEvent {
1481
+ /**
1482
+ * Emitted when the app is ready to use.
1483
+ *
1484
+ * @since 5.2.0
1485
+ */
1486
+ bundle: BundleInfo;
1487
+ status: string;
1488
+ }
1489
+ export interface ChannelPrivateEvent {
1490
+ /**
1491
+ * Emitted when attempting to set a channel that doesn't allow device self-assignment.
1492
+ *
1493
+ * @since 7.34.0
1494
+ */
1495
+ channel: string;
1496
+ message: string;
1497
+ }
1498
+ export interface ManifestEntry {
1499
+ file_name: string | null;
1500
+ file_hash: string | null;
1501
+ download_url: string | null;
1502
+ }
1503
+ export interface LatestVersion {
172
1504
  /**
173
- * Res of getLatest method
1505
+ * Result of getLatest method
174
1506
  *
175
1507
  * @since 4.0.0
176
1508
  */
177
1509
  version: string;
1510
+ /**
1511
+ * @since 6
1512
+ */
1513
+ checksum?: string;
1514
+ /**
1515
+ * Indicates whether the update was flagged as breaking by the backend.
1516
+ *
1517
+ * @since 7.22.0
1518
+ */
1519
+ breaking?: boolean;
1520
+ /**
1521
+ * @deprecated Use {@link LatestVersion.breaking} instead.
1522
+ */
178
1523
  major?: boolean;
1524
+ /**
1525
+ * Optional message from the server.
1526
+ * When no new version is available, this will be "No new version available".
1527
+ */
179
1528
  message?: string;
180
1529
  sessionKey?: string;
1530
+ /**
1531
+ * Error code from the server, if any.
1532
+ * Common values:
1533
+ * - `"no_new_version_available"`: Device is already on the latest version (not a failure)
1534
+ * - Other error codes indicate actual failures in the update process
1535
+ */
181
1536
  error?: string;
1537
+ /**
1538
+ * The previous/current version name (provided for reference).
1539
+ */
182
1540
  old?: string;
1541
+ /**
1542
+ * Download URL for the bundle (when a new version is available).
1543
+ */
183
1544
  url?: string;
1545
+ /**
1546
+ * File list for delta updates (when using multi-file downloads).
1547
+ * @since 6.1
1548
+ */
1549
+ manifest?: ManifestEntry[];
1550
+ /**
1551
+ * Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release).
1552
+ * @since 7.35.0
1553
+ */
1554
+ link?: string;
1555
+ /**
1556
+ * Optional comment or description for this bundle version.
1557
+ * @since 7.35.0
1558
+ */
1559
+ comment?: string;
184
1560
  }
185
1561
  export interface BundleInfo {
186
1562
  id: string;
@@ -191,8 +1567,15 @@ export interface BundleInfo {
191
1567
  }
192
1568
  export interface SetChannelOptions {
193
1569
  channel: string;
1570
+ triggerAutoUpdate?: boolean;
1571
+ }
1572
+ export interface UnsetChannelOptions {
1573
+ triggerAutoUpdate?: boolean;
194
1574
  }
195
1575
  export interface SetCustomIdOptions {
1576
+ /**
1577
+ * Custom identifier to associate with the device. Use an empty string to clear any saved value.
1578
+ */
196
1579
  customId: string;
197
1580
  }
198
1581
  export interface DelayCondition {
@@ -203,259 +1586,395 @@ export interface DelayCondition {
203
1586
  kind: DelayUntilNext;
204
1587
  value?: string;
205
1588
  }
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 {
1589
+ export interface GetLatestOptions {
217
1590
  /**
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
- *
220
- * @returns {Promise<BundleInfo>} an Promise resolved directly
221
- * @throws An error if something went wrong
1591
+ * The channel to get the latest version for
1592
+ * The channel must allow 'self_assign' for this to work
1593
+ * @since 6.8.0
1594
+ * @default undefined
1595
+ */
1596
+ channel?: string;
1597
+ }
1598
+ export interface AppReadyResult {
1599
+ bundle: BundleInfo;
1600
+ }
1601
+ export interface UpdateUrl {
1602
+ url: string;
1603
+ }
1604
+ export interface StatsUrl {
1605
+ url: string;
1606
+ }
1607
+ export interface ChannelUrl {
1608
+ url: string;
1609
+ }
1610
+ /**
1611
+ * 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.
1612
+ * 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.
1613
+ */
1614
+ export interface DownloadOptions {
1615
+ /**
1616
+ * 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.)
222
1617
  */
223
- notifyAppReady(): Promise<BundleInfo>;
1618
+ url: string;
224
1619
  /**
225
- * 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
226
- *
227
- * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.
228
- * @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.)
229
- * @param version set the version code/name of this bundle/version
230
- * @example https://example.com/versions/{version}/dist.zip
1620
+ * The version code/name of this bundle/version
231
1621
  */
232
- download(options: {
233
- url: string;
234
- version: string;
235
- sessionKey?: string;
236
- checksum?: string;
237
- }): Promise<BundleInfo>;
1622
+ version: string;
238
1623
  /**
239
- * Set the next bundle to be used when the app is reloaded.
240
- *
241
- * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle id.
242
- * @param id The bundle id to set as current, next time the app is reloaded. See {@link BundleInfo.id}
243
- * @throws An error if there are is no index.html file inside the bundle folder.
1624
+ * The session key for the update, when the bundle is encrypted with a session key
1625
+ * @since 4.0.0
1626
+ * @default undefined
244
1627
  */
245
- next(options: {
246
- id: string;
247
- }): Promise<BundleInfo>;
1628
+ sessionKey?: string;
248
1629
  /**
249
- * Set the current bundle and immediately reloads the app.
1630
+ * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted
1631
+ * @since 4.0.0
1632
+ * @default undefined
1633
+ */
1634
+ checksum?: string;
1635
+ /**
1636
+ * The manifest for multi-file downloads
1637
+ * @since 6.1.0
1638
+ * @default undefined
1639
+ */
1640
+ manifest?: ManifestEntry[];
1641
+ }
1642
+ export interface BundleId {
1643
+ id: string;
1644
+ }
1645
+ export interface BundleListResult {
1646
+ bundles: BundleInfo[];
1647
+ }
1648
+ export interface ResetOptions {
1649
+ toLastSuccessful: boolean;
1650
+ }
1651
+ export interface ListOptions {
1652
+ /**
1653
+ * 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.
1654
+ * @since 6.14.0
1655
+ * @default false
1656
+ */
1657
+ raw?: boolean;
1658
+ }
1659
+ export interface CurrentBundleResult {
1660
+ bundle: BundleInfo;
1661
+ native: string;
1662
+ }
1663
+ export interface MultiDelayConditions {
1664
+ delayConditions: DelayCondition[];
1665
+ }
1666
+ export interface BuiltinVersion {
1667
+ version: string;
1668
+ }
1669
+ export interface DeviceId {
1670
+ deviceId: string;
1671
+ }
1672
+ export interface PluginVersion {
1673
+ version: string;
1674
+ }
1675
+ export interface AutoUpdateEnabled {
1676
+ enabled: boolean;
1677
+ }
1678
+ export interface AutoUpdateAvailable {
1679
+ available: boolean;
1680
+ }
1681
+ export interface SetShakeMenuOptions {
1682
+ enabled: boolean;
1683
+ }
1684
+ export interface ShakeMenuEnabled {
1685
+ enabled: boolean;
1686
+ }
1687
+ export interface SetShakeChannelSelectorOptions {
1688
+ enabled: boolean;
1689
+ }
1690
+ export interface ShakeChannelSelectorEnabled {
1691
+ enabled: boolean;
1692
+ }
1693
+ export interface GetAppIdRes {
1694
+ appId: string;
1695
+ }
1696
+ export interface SetAppIdOptions {
1697
+ appId: string;
1698
+ }
1699
+ /**
1700
+ * Options for {@link CapacitorUpdaterPlugin.getAppUpdateInfo}.
1701
+ *
1702
+ * @since 8.0.0
1703
+ */
1704
+ export interface GetAppUpdateInfoOptions {
1705
+ /**
1706
+ * Two-letter country code (ISO 3166-1 alpha-2) for the App Store lookup.
1707
+ *
1708
+ * This is required on iOS to get accurate App Store information, as app
1709
+ * availability and versions can vary by country.
250
1710
  *
251
- * @param id The bundle id to set as current. See {@link BundleInfo.id}
252
- * @returns {Promise<Void>} An empty promise.
253
- * @throws An error if there are is no index.html file inside the bundle folder.
1711
+ * Examples: "US", "GB", "DE", "JP", "FR"
1712
+ *
1713
+ * On Android, this option is ignored as the Play Store handles region
1714
+ * detection automatically.
1715
+ *
1716
+ * @since 8.0.0
254
1717
  */
255
- set(options: {
256
- id: string;
257
- }): Promise<void>;
1718
+ country?: string;
1719
+ }
1720
+ /**
1721
+ * Information about app updates available in the App Store or Play Store.
1722
+ *
1723
+ * @since 8.0.0
1724
+ */
1725
+ export interface AppUpdateInfo {
258
1726
  /**
259
- * Delete bundle in storage
1727
+ * The currently installed version name (e.g., "1.2.3").
260
1728
  *
261
- * @returns {Promise<void>} an empty Promise when the bundle is deleted
262
- * @param id The bundle id to delete (note, this is the bundle id, NOT the version name)
263
- * @throws An error if the something went wrong
1729
+ * @since 8.0.0
264
1730
  */
265
- delete(options: {
266
- id: string;
267
- }): Promise<void>;
1731
+ currentVersionName: string;
268
1732
  /**
269
- * Get all available bundles
1733
+ * The version name available in the store, if an update is available.
1734
+ * May be undefined if no update information is available.
270
1735
  *
271
- * @returns {Promise<{bundles: BundleInfo[]}>} an Promise witht the bundles list
272
- * @throws An error if the something went wrong
1736
+ * @since 8.0.0
273
1737
  */
274
- list(): Promise<{
275
- bundles: BundleInfo[];
276
- }>;
1738
+ availableVersionName?: string;
277
1739
  /**
278
- * Set the `builtin` bundle (the one sent to Apple store / Google play store ) as current bundle
1740
+ * The currently installed version code (Android) or build number (iOS).
279
1741
  *
280
- * @returns {Promise<void>} an empty Promise
281
- * @param toLastSuccessful [false] if yes it reset to to the last successfully loaded bundle instead of `builtin`
282
- * @throws An error if the something went wrong
1742
+ * @since 8.0.0
283
1743
  */
284
- reset(options?: {
285
- toLastSuccessful?: boolean;
286
- }): Promise<void>;
1744
+ currentVersionCode: string;
287
1745
  /**
288
- * Get the current bundle, if none are set it returns `builtin`, currentNative is the original bundle installed on the device
1746
+ * The version code available in the store (Android only).
1747
+ * On iOS, this will be the same as `availableVersionName`.
289
1748
  *
290
- * @returns {Promise<{ bundle: BundleInfo, native: string }>} an Promise with the current bundle info
291
- * @throws An error if the something went wrong
1749
+ * @since 8.0.0
292
1750
  */
293
- current(): Promise<{
294
- bundle: BundleInfo;
295
- native: string;
296
- }>;
1751
+ availableVersionCode?: string;
297
1752
  /**
298
- * Reload the view
1753
+ * The release date of the available version (iOS only).
1754
+ * Format: ISO 8601 date string.
299
1755
  *
300
- * @returns {Promise<void>} an Promise resolved when the view is reloaded
301
- * @throws An error if the something went wrong
1756
+ * @since 8.0.0
302
1757
  */
303
- reload(): Promise<void>;
1758
+ availableVersionReleaseDate?: string;
304
1759
  /**
305
- * Set DelayCondition, skip updates until one of the conditions is met
1760
+ * The current update availability status.
306
1761
  *
307
- * @returns {Promise<void>} an Promise resolved directly
308
- * @param options are the {@link DelayCondition} list to set
1762
+ * @since 8.0.0
1763
+ */
1764
+ updateAvailability: AppUpdateAvailability;
1765
+ /**
1766
+ * The priority of the update as set by the developer in Play Console (Android only).
1767
+ * Values range from 0 (default/lowest) to 5 (highest priority).
309
1768
  *
310
- * @example
311
- * setMultiDelay({ delayConditions: [{ kind: 'kill' }, { kind: 'background', value: '300000' }] })
312
- * // installs the update after the user kills the app or after a background of 300000 ms (5 minutes)
1769
+ * Use this to decide whether to show an update prompt or force an update.
313
1770
  *
314
- * @example
315
- * setMultiDelay({ delayConditions: [{ kind: 'date', value: '2022-09-14T06:14:11.920Z' }] })
316
- * // installs the update after the specific iso8601 date is expired
1771
+ * @since 8.0.0
1772
+ */
1773
+ updatePriority?: number;
1774
+ /**
1775
+ * Whether an immediate update is allowed (Android only).
317
1776
  *
318
- * @example
319
- * setMultiDelay({ delayConditions: [{ kind: 'background' }] })
320
- * // installs the update after the the first background (default behaviour without setting delay)
1777
+ * If `true`, you can call {@link CapacitorUpdaterPlugin.performImmediateUpdate}.
321
1778
  *
322
- * @throws An error if the something went wrong
323
- * @since 4.3.0
1779
+ * @since 8.0.0
324
1780
  */
325
- setMultiDelay(options: {
326
- delayConditions: DelayCondition[];
327
- }): Promise<void>;
1781
+ immediateUpdateAllowed?: boolean;
328
1782
  /**
329
- * Set DelayCondition, skip updates until the condition is met
1783
+ * Whether a flexible update is allowed (Android only).
330
1784
  *
331
- * @deprecated use setMultiDelay instead passing a single value in array
332
- * @returns {Promise<void>} an Promise resolved directly
333
- * @param options is the {@link DelayCondition} to set
334
- * @throws An error if the something went wrong
335
- * @since 4.0.0
1785
+ * If `true`, you can call {@link CapacitorUpdaterPlugin.startFlexibleUpdate}.
1786
+ *
1787
+ * @since 8.0.0
336
1788
  */
337
- setDelay(options: DelayCondition): Promise<void>;
1789
+ flexibleUpdateAllowed?: boolean;
338
1790
  /**
339
- * Cancel delay to updates as usual
1791
+ * Number of days since the update became available (Android only).
340
1792
  *
341
- * @returns {Promise<void>} an Promise resolved directly
342
- * @throws An error if the something went wrong
343
- * @since 4.0.0
1793
+ * Use this to implement "update nagging" - remind users more frequently
1794
+ * as the update ages.
1795
+ *
1796
+ * @since 8.0.0
344
1797
  */
345
- cancelDelay(): Promise<void>;
1798
+ clientVersionStalenessDays?: number;
346
1799
  /**
347
- * Get Latest bundle available from update Url
1800
+ * The current install status of a flexible update (Android only).
348
1801
  *
349
- * @returns {Promise<latestVersion>} an Promise resolved when url is loaded
350
- * @throws An error if the something went wrong
351
- * @since 4.0.0
1802
+ * @since 8.0.0
352
1803
  */
353
- getLatest(): Promise<latestVersion>;
1804
+ installStatus?: FlexibleUpdateInstallStatus;
354
1805
  /**
355
- * Set Channel for this device
1806
+ * The minimum OS version required for the available update (iOS only).
356
1807
  *
357
- * @returns {Promise<channelRes>} an Promise resolved when channel is set
358
- * @param options is the {@link SetChannelOptions} channel to set
359
- * @throws An error if the something went wrong
360
- * @since 4.7.0
1808
+ * @since 8.0.0
361
1809
  */
362
- setChannel(options: SetChannelOptions): Promise<channelRes>;
1810
+ minimumOsVersion?: string;
1811
+ }
1812
+ /**
1813
+ * Options for {@link CapacitorUpdaterPlugin.openAppStore}.
1814
+ *
1815
+ * @since 8.0.0
1816
+ */
1817
+ export interface OpenAppStoreOptions {
363
1818
  /**
364
- * get Channel for this device
1819
+ * The Android package name to open in the Play Store.
365
1820
  *
366
- * @returns {Promise<channelRes>} an Promise resolved with channel info
367
- * @throws An error if the something went wrong
368
- * @since 4.8.0
1821
+ * If not specified, uses the current app's package name.
1822
+ * Use this to open a different app's store page.
1823
+ *
1824
+ * Only used on Android.
1825
+ *
1826
+ * @since 8.0.0
369
1827
  */
370
- getChannel(): Promise<getChannelRes>;
1828
+ packageName?: string;
371
1829
  /**
372
- * Set Channel for this device
1830
+ * The iOS App Store ID to open.
373
1831
  *
374
- * @returns {Promise<void>} an Promise resolved instantly
375
- * @param options is the {@link SetCustomIdOptions} customId to set
376
- * @throws An error if the something went wrong
377
- * @since 4.9.0
1832
+ * If not specified, uses the current app's bundle identifier to look up the app.
1833
+ * Use this to open a different app's store page or when automatic lookup fails.
1834
+ *
1835
+ * Only used on iOS.
1836
+ *
1837
+ * @since 8.0.0
378
1838
  */
379
- setCustomId(options: SetCustomIdOptions): Promise<void>;
1839
+ appId?: string;
1840
+ }
1841
+ /**
1842
+ * State information for flexible update progress (Android only).
1843
+ *
1844
+ * @since 8.0.0
1845
+ */
1846
+ export interface FlexibleUpdateState {
380
1847
  /**
381
- * Listen for download event in the App, let you know when the download is started, loading and finished
1848
+ * The current installation status.
382
1849
  *
383
- * @since 2.0.11
1850
+ * @since 8.0.0
384
1851
  */
385
- addListener(eventName: "download", listenerFunc: DownloadChangeListener): Promise<PluginListenerHandle> & PluginListenerHandle;
1852
+ installStatus: FlexibleUpdateInstallStatus;
386
1853
  /**
387
- * Listen for no need to update event, usefull when you want force check every time the app is launched
1854
+ * Number of bytes downloaded so far.
1855
+ * Only available during the `DOWNLOADING` status.
388
1856
  *
389
- * @since 4.0.0
1857
+ * @since 8.0.0
390
1858
  */
391
- addListener(eventName: "noNeedUpdate", listenerFunc: NoNeedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
1859
+ bytesDownloaded?: number;
392
1860
  /**
393
- * Listen for availbale update event, usefull when you want to force check every time the app is launched
1861
+ * Total number of bytes to download.
1862
+ * Only available during the `DOWNLOADING` status.
394
1863
  *
395
- * @since 4.0.0
1864
+ * @since 8.0.0
396
1865
  */
397
- addListener(eventName: "updateAvailable", listenerFunc: UpdateAvailabledListener): Promise<PluginListenerHandle> & PluginListenerHandle;
1866
+ totalBytesToDownload?: number;
1867
+ }
1868
+ /**
1869
+ * Result of an app update operation.
1870
+ *
1871
+ * @since 8.0.0
1872
+ */
1873
+ export interface AppUpdateResult {
398
1874
  /**
399
- * Listen for download event in the App, let you know when the download is started, loading and finished
1875
+ * The result code of the update operation.
400
1876
  *
401
- * @since 4.0.0
1877
+ * @since 8.0.0
402
1878
  */
403
- addListener(eventName: "downloadComplete", listenerFunc: DownloadCompleteListener): Promise<PluginListenerHandle> & PluginListenerHandle;
1879
+ code: AppUpdateResultCode;
1880
+ }
1881
+ /**
1882
+ * Update availability status.
1883
+ *
1884
+ * @since 8.0.0
1885
+ */
1886
+ export declare enum AppUpdateAvailability {
404
1887
  /**
405
- * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
406
- *
407
- * @since 2.3.0
1888
+ * Update availability is unknown.
1889
+ * This typically means the check hasn't completed or failed.
408
1890
  */
409
- addListener(eventName: "majorAvailable", listenerFunc: MajorAvailableListener): Promise<PluginListenerHandle> & PluginListenerHandle;
1891
+ UNKNOWN = 0,
410
1892
  /**
411
- * Listen for update fail event in the App, let you know when update has fail to install at next app start
412
- *
413
- * @since 2.3.0
1893
+ * No update is available.
1894
+ * The installed version is the latest.
414
1895
  */
415
- addListener(eventName: "updateFailed", listenerFunc: UpdateFailedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
1896
+ UPDATE_NOT_AVAILABLE = 1,
416
1897
  /**
417
- * Listen for download fail event in the App, let you know when download has fail finished
418
- *
419
- * @since 4.0.0
1898
+ * An update is available for download.
420
1899
  */
421
- addListener(eventName: "downloadFailed", listenerFunc: DownloadFailedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
1900
+ UPDATE_AVAILABLE = 2,
422
1901
  /**
423
- * Listen for download fail event in the App, let you know when download has fail finished
424
- *
425
- * @since 4.3.0
1902
+ * An update is currently being downloaded or installed.
426
1903
  */
427
- addListener(eventName: "appReloaded", listenerFunc: AppReloadedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
1904
+ UPDATE_IN_PROGRESS = 3
1905
+ }
1906
+ /**
1907
+ * Installation status for flexible updates (Android only).
1908
+ *
1909
+ * @since 8.0.0
1910
+ */
1911
+ export declare enum FlexibleUpdateInstallStatus {
428
1912
  /**
429
- * Get unique ID used to identify device (sent to auto update server)
430
- *
431
- * @returns {Promise<{ deviceId: string }>} an Promise with id for this device
432
- * @throws An error if the something went wrong
1913
+ * Unknown install status.
433
1914
  */
434
- getDeviceId(): Promise<{
435
- deviceId: string;
436
- }>;
1915
+ UNKNOWN = 0,
437
1916
  /**
438
- * Get the native Capacitor Updater plugin version (sent to auto update server)
439
- *
440
- * @returns {Promise<{ id: string }>} an Promise with version for this device
441
- * @throws An error if the something went wrong
1917
+ * Download is pending and will start soon.
442
1918
  */
443
- getPluginVersion(): Promise<{
444
- version: string;
445
- }>;
1919
+ PENDING = 1,
446
1920
  /**
447
- * Get the state of auto update config. This will return `false` in manual mode.
448
- *
449
- * @returns {Promise<{enabled: boolean}>} The status for auto update.
450
- * @throws An error if the something went wrong
1921
+ * Download is in progress.
1922
+ * Check `bytesDownloaded` and `totalBytesToDownload` for progress.
451
1923
  */
452
- isAutoUpdateEnabled(): Promise<{
453
- enabled: boolean;
454
- }>;
1924
+ DOWNLOADING = 2,
455
1925
  /**
456
- * Remove all listeners for this plugin.
457
- *
458
- * @since 1.0.0
1926
+ * The update is being installed.
459
1927
  */
460
- removeAllListeners(): Promise<void>;
1928
+ INSTALLING = 3,
1929
+ /**
1930
+ * The update has been installed.
1931
+ * The app needs to be restarted to use the new version.
1932
+ */
1933
+ INSTALLED = 4,
1934
+ /**
1935
+ * The update failed to download or install.
1936
+ */
1937
+ FAILED = 5,
1938
+ /**
1939
+ * The update was canceled by the user.
1940
+ */
1941
+ CANCELED = 6,
1942
+ /**
1943
+ * The update has been downloaded and is ready to install.
1944
+ * Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install.
1945
+ */
1946
+ DOWNLOADED = 11
1947
+ }
1948
+ /**
1949
+ * Result codes for app update operations.
1950
+ *
1951
+ * @since 8.0.0
1952
+ */
1953
+ export declare enum AppUpdateResultCode {
1954
+ /**
1955
+ * The update completed successfully.
1956
+ */
1957
+ OK = 0,
1958
+ /**
1959
+ * The user canceled the update.
1960
+ */
1961
+ CANCELED = 1,
1962
+ /**
1963
+ * The update failed.
1964
+ */
1965
+ FAILED = 2,
1966
+ /**
1967
+ * No update is available.
1968
+ */
1969
+ NOT_AVAILABLE = 3,
1970
+ /**
1971
+ * The requested update type is not allowed.
1972
+ * For example, trying to perform an immediate update when only flexible is allowed.
1973
+ */
1974
+ NOT_ALLOWED = 4,
1975
+ /**
1976
+ * Required information is missing.
1977
+ * This can happen if {@link CapacitorUpdaterPlugin.getAppUpdateInfo} wasn't called first.
1978
+ */
1979
+ INFO_MISSING = 5
461
1980
  }