@capgo/cordova-updater 8.1.1

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