@capgo/capacitor-updater 7.27.7 → 7.27.8

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.
@@ -312,243 +312,566 @@ declare module '@capacitor/cli' {
312
312
  }
313
313
  export interface CapacitorUpdaterPlugin {
314
314
  /**
315
- * Notify Capacitor Updater that the current bundle is working (a rollback will occur if this method is not called on every app launch)
316
- * By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur.
317
- * Change this behaviour with {@link appReadyTimeout}
315
+ * Notify the native layer that JavaScript initialized successfully.
318
316
  *
319
- * @returns {Promise<AppReadyResult>} an Promise resolved directly
320
- * @throws {Error}
317
+ * **CRITICAL: You must call this method on every app launch to prevent automatic rollback.**
318
+ *
319
+ * This is a simple notification to confirm that your bundle's JavaScript loaded and executed.
320
+ * The native web server successfully served the bundle files and your JS runtime started.
321
+ * That's all it checks - nothing more complex.
322
+ *
323
+ * **What triggers rollback:**
324
+ * - NOT calling this method within the timeout (default: 10 seconds)
325
+ * - Complete JavaScript failure (bundle won't load at all)
326
+ *
327
+ * **What does NOT trigger rollback:**
328
+ * - Runtime errors after initialization (API failures, crashes, etc.)
329
+ * - Network request failures
330
+ * - Application logic errors
331
+ *
332
+ * **IMPORTANT: Call this BEFORE any network requests.**
333
+ * Don't wait for APIs, data loading, or async operations. Call it as soon as your
334
+ * JavaScript bundle starts executing to confirm the bundle itself is valid.
335
+ *
336
+ * Best practices:
337
+ * - Call immediately in your app entry point (main.js, app component mount, etc.)
338
+ * - Don't put it after network calls or heavy initialization
339
+ * - Don't wrap it in try/catch with conditions
340
+ * - Adjust {@link PluginsConfig.CapacitorUpdater.appReadyTimeout} if you need more time
341
+ *
342
+ * @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.
321
343
  */
322
344
  notifyAppReady(): Promise<AppReadyResult>;
323
345
  /**
324
- * Set the updateUrl for the app, this will be used to check for updates.
346
+ * Set the update URL for the app dynamically at runtime.
347
+ *
348
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.updateUrl} config value.
349
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
325
350
  *
326
- * @param options contains the URL to use for checking for updates.
327
- * @returns {Promise<void>}
328
- * @throws {Error}
351
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
352
+ * Otherwise, the URL will reset to the config value on next app launch.
353
+ *
354
+ * @param options Contains the URL to use for checking for updates.
355
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
356
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
329
357
  * @since 5.4.0
330
358
  */
331
359
  setUpdateUrl(options: UpdateUrl): Promise<void>;
332
360
  /**
333
- * Set the statsUrl for the app, this will be used to send statistics. Passing an empty string will disable statistics gathering.
361
+ * Set the statistics URL for the app dynamically at runtime.
362
+ *
363
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.statsUrl} config value.
364
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
365
+ *
366
+ * Pass an empty string to disable statistics gathering entirely.
367
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
334
368
  *
335
- * @param options contains the URL to use for sending statistics.
336
- * @returns {Promise<void>}
337
- * @throws {Error}
369
+ * @param options Contains the URL to use for sending statistics, or an empty string to disable.
370
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
371
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
338
372
  * @since 5.4.0
339
373
  */
340
374
  setStatsUrl(options: StatsUrl): Promise<void>;
341
375
  /**
342
- * Set the channelUrl for the app, this will be used to set the channel.
376
+ * Set the channel URL for the app dynamically at runtime.
343
377
  *
344
- * @param options contains the URL to use for setting the channel.
345
- * @returns {Promise<void>}
346
- * @throws {Error}
378
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.channelUrl} config value.
379
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
380
+ *
381
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
382
+ * Otherwise, the URL will reset to the config value on next app launch.
383
+ *
384
+ * @param options Contains the URL to use for channel operations.
385
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
386
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
347
387
  * @since 5.4.0
348
388
  */
349
389
  setChannelUrl(options: ChannelUrl): Promise<void>;
350
390
  /**
351
- * Download a new bundle from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files
391
+ * Download a new bundle from the provided URL for later installation.
392
+ *
393
+ * The downloaded bundle is stored locally but not activated. To use it:
394
+ * - Call {@link next} to set it for installation on next app backgrounding/restart
395
+ * - Call {@link set} to activate it immediately (destroys current JavaScript context)
396
+ *
397
+ * The URL should point to a zip file containing either:
398
+ * - Your app files directly in the zip root, or
399
+ * - A single folder containing all your app files
400
+ *
401
+ * The bundle must include an `index.html` file at the root level.
402
+ *
403
+ * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.
404
+ * For multi-file partial updates, provide the `manifest` array.
405
+ *
406
+ * @example
407
+ * const bundle = await CapacitorUpdater.download({
408
+ * url: `https://example.com/versions/${version}/dist.zip`,
409
+ * version: version
410
+ * });
411
+ * // Bundle is downloaded but not active yet
412
+ * await CapacitorUpdater.next({ id: bundle.id }); // Will activate on next background
352
413
  *
353
- * @example const bundle = await CapacitorUpdater.download({ url: `https://example.com/versions/${version}/dist.zip`, version });
354
- * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.
355
414
  * @param options The {@link DownloadOptions} for downloading a new bundle zip.
415
+ * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the downloaded bundle.
416
+ * @throws {Error} If the download fails or the bundle is invalid.
356
417
  */
357
418
  download(options: DownloadOptions): Promise<BundleInfo>;
358
419
  /**
359
- * Set the next bundle to be used when the app is reloaded.
420
+ * Set the next bundle to be activated when the app backgrounds or restarts.
360
421
  *
361
- * @param options Contains the ID of the next Bundle to set on next app launch. {@link BundleInfo.id}
362
- * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle id.
363
- * @throws {Error} When there is no index.html file inside the bundle folder.
422
+ * This is the recommended way to apply updates as it doesn't interrupt the user's current session.
423
+ * The bundle will be activated when:
424
+ * - The app is backgrounded (user switches away), or
425
+ * - The app is killed and relaunched, or
426
+ * - {@link reload} is called manually
427
+ *
428
+ * Unlike {@link set}, this method does NOT destroy the current JavaScript context immediately.
429
+ * Your app continues running normally until one of the above events occurs.
430
+ *
431
+ * Use {@link setMultiDelay} to add additional conditions before the update is applied.
432
+ *
433
+ * @param options Contains the ID of the bundle to set as next. Use {@link BundleInfo.id} from a downloaded bundle.
434
+ * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.
435
+ * @throws {Error} When there is no index.html file inside the bundle folder or the bundle doesn't exist.
364
436
  */
365
437
  next(options: BundleId): Promise<BundleInfo>;
366
438
  /**
367
439
  * Set the current bundle and immediately reloads the app.
368
440
  *
441
+ * **IMPORTANT: This is a terminal operation that destroys the current JavaScript context.**
442
+ *
443
+ * When you call this method:
444
+ * - The entire JavaScript context is immediately destroyed
445
+ * - The app reloads from a different folder with different files
446
+ * - NO code after this call will execute
447
+ * - NO promises will resolve
448
+ * - NO callbacks will fire
449
+ * - Event listeners registered after this call are unreliable and may never fire
450
+ *
451
+ * The reload happens automatically - you don't need to do anything else.
452
+ * If you need to preserve state like the current URL path, use the {@link PluginsConfig.CapacitorUpdater.keepUrlPathAfterReload} config option.
453
+ * For other state preservation needs, save your data before calling this method (e.g., to localStorage).
454
+ *
455
+ * **Do not** try to execute additional logic after calling `set()` - it won't work as expected.
456
+ *
369
457
  * @param options A {@link BundleId} object containing the new bundle id to set as current.
370
- * @returns {Promise<void>}
371
- * @throws {Error} When there are is no index.html file inside the bundle folder.
458
+ * @returns {Promise<void>} A promise that will never resolve because the JavaScript context is destroyed.
459
+ * @throws {Error} When there is no index.html file inside the bundle folder.
372
460
  */
373
461
  set(options: BundleId): Promise<void>;
374
462
  /**
375
- * Deletes the specified bundle from the native app storage. Use with {@link list} to get the stored Bundle IDs.
463
+ * Delete a bundle from local storage to free up disk space.
464
+ *
465
+ * You cannot delete:
466
+ * - The currently active bundle
467
+ * - The `builtin` bundle (the version shipped with your app)
468
+ * - The bundle set as `next` (call {@link next} with a different bundle first)
376
469
  *
377
- * @param options A {@link BundleId} object containing the ID of a bundle to delete (note, this is the bundle id, NOT the version name)
378
- * @returns {Promise<void>} When the bundle is deleted
379
- * @throws {Error}
470
+ * Use {@link list} to get all available bundle IDs.
471
+ *
472
+ * **Note:** The bundle ID is NOT the same as the version name.
473
+ * Use the `id` field from {@link BundleInfo}, not the `version` field.
474
+ *
475
+ * @param options A {@link BundleId} object containing the bundle ID to delete.
476
+ * @returns {Promise<void>} Resolves when the bundle is successfully deleted.
477
+ * @throws {Error} If the bundle is currently in use or doesn't exist.
380
478
  */
381
479
  delete(options: BundleId): Promise<void>;
382
480
  /**
383
- * Mark an installed bundle as errored. Only available when {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} is true.
481
+ * Manually mark a bundle as failed/errored in manual update mode.
482
+ *
483
+ * This is useful when you detect that a bundle has critical issues and want to prevent
484
+ * it from being used again. The bundle status will be changed to `error` and the plugin
485
+ * will avoid using this bundle in the future.
384
486
  *
385
- * @param options A {@link BundleId} object containing the bundle id to mark as errored.
386
- * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} for the bundle.
387
- * @throws {Error} When the bundle does not exist or the feature is disabled.
487
+ * **Requirements:**
488
+ * - {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} must be set to `true`
489
+ * - Only works in manual update mode (when autoUpdate is disabled)
490
+ *
491
+ * Common use case: After downloading and testing a bundle, you discover it has critical
492
+ * bugs and want to mark it as failed so it won't be retried.
493
+ *
494
+ * @param options A {@link BundleId} object containing the bundle ID to mark as errored.
495
+ * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} with status set to `error`.
496
+ * @throws {Error} When the bundle does not exist or `allowManualBundleError` is false.
388
497
  * @since 7.20.0
389
498
  */
390
499
  setBundleError(options: BundleId): Promise<BundleInfo>;
391
500
  /**
392
- * Get all locally downloaded bundles in your app
501
+ * Get all locally downloaded bundles stored in your app.
502
+ *
503
+ * This returns all bundles that have been downloaded and are available locally, including:
504
+ * - The currently active bundle
505
+ * - The `builtin` bundle (shipped with your app)
506
+ * - Any downloaded bundles waiting to be activated
507
+ * - Failed bundles (with `error` status)
393
508
  *
394
- * @returns {Promise<BundleListResult>} A Promise containing the {@link BundleListResult.bundles}
395
- * @param options The {@link ListOptions} for listing bundles
396
- * @throws {Error}
509
+ * Use this to:
510
+ * - Check available disk space by counting bundles
511
+ * - Delete old bundles with {@link delete}
512
+ * - Monitor bundle download status
513
+ *
514
+ * @param options The {@link ListOptions} for customizing the bundle list output.
515
+ * @returns {Promise<BundleListResult>} A promise containing the array of {@link BundleInfo} objects.
516
+ * @throws {Error} If the operation fails.
397
517
  */
398
518
  list(options?: ListOptions): Promise<BundleListResult>;
399
519
  /**
400
- * Reset the app to the `builtin` bundle (the one sent to Apple App Store / Google Play Store ) or the last successfully loaded bundle.
520
+ * Reset the app to a known good bundle.
521
+ *
522
+ * This method helps recover from problematic updates by reverting to either:
523
+ * - The `builtin` bundle (the original version shipped with your app to App Store/Play Store)
524
+ * - The last successfully loaded bundle (most recent bundle that worked correctly)
525
+ *
526
+ * **IMPORTANT: This triggers an immediate app reload, destroying the current JavaScript context.**
527
+ * See {@link set} for details on the implications of this operation.
401
528
  *
402
- * @param options Containing {@link ResetOptions.toLastSuccessful}, `true` resets to the builtin bundle and `false` will reset to the last successfully loaded bundle.
403
- * @returns {Promise<void>}
404
- * @throws {Error}
529
+ * Use cases:
530
+ * - Emergency recovery when an update causes critical issues
531
+ * - Testing rollback functionality
532
+ * - Providing users a "reset to factory" option
533
+ *
534
+ * @param options {@link ResetOptions} to control reset behavior. If `toLastSuccessful` is `false` (or omitted), resets to builtin. If `true`, resets to last successful bundle.
535
+ * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
536
+ * @throws {Error} If the reset operation fails.
405
537
  */
406
538
  reset(options?: ResetOptions): Promise<void>;
407
539
  /**
408
- * Get the current bundle, if none are set it returns `builtin`. currentNative is the original bundle installed on the device
540
+ * Get information about the currently active bundle.
541
+ *
542
+ * Returns:
543
+ * - `bundle`: The currently active bundle information
544
+ * - `native`: The version of the builtin bundle (the original app version from App/Play Store)
545
+ *
546
+ * If no updates have been applied, `bundle.id` will be `"builtin"`, indicating the app
547
+ * is running the original version shipped with the native app.
409
548
  *
410
- * @returns {Promise<CurrentBundleResult>} A Promise evaluating to the {@link CurrentBundleResult}
411
- * @throws {Error}
549
+ * Use this to:
550
+ * - Display the current version to users
551
+ * - Check if an update is currently active
552
+ * - Compare against available updates
553
+ * - Log the active bundle for debugging
554
+ *
555
+ * @returns {Promise<CurrentBundleResult>} A promise with the current bundle and native version info.
556
+ * @throws {Error} If the operation fails.
412
557
  */
413
558
  current(): Promise<CurrentBundleResult>;
414
559
  /**
415
- * Reload the view
560
+ * Manually reload the app to apply a pending update.
561
+ *
562
+ * This triggers the same reload behavior that happens automatically when the app backgrounds.
563
+ * If you've called {@link next} to queue an update, calling `reload()` will apply it immediately.
564
+ *
565
+ * **IMPORTANT: This destroys the current JavaScript context immediately.**
566
+ * See {@link set} for details on the implications of this operation.
416
567
  *
417
- * @returns {Promise<void>} A Promise which is resolved when the view is reloaded
418
- * @throws {Error}
568
+ * Common use cases:
569
+ * - Applying an update immediately after download instead of waiting for backgrounding
570
+ * - Providing a "Restart now" button to users after an update is ready
571
+ * - Testing update flows during development
572
+ *
573
+ * If no update is pending (no call to {@link next}), this simply reloads the current bundle.
574
+ *
575
+ * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
576
+ * @throws {Error} If the reload operation fails.
419
577
  */
420
578
  reload(): Promise<void>;
421
579
  /**
422
- * Sets a {@link DelayCondition} array containing conditions that the Plugin will use to delay the update.
423
- * After all conditions are met, the update process will run start again as usual, so update will be installed after a backgrounding or killing the app.
424
- * For the `date` kind, the value should be an iso8601 date string.
425
- * For the `background` kind, the value should be a number in milliseconds.
426
- * For the `nativeVersion` kind, the value should be the version number.
427
- * For the `kill` kind, the value is not used.
428
- * The function has inconsistent behavior the option kill do trigger the update after the first kill and not after the next background like other options. This will be fixed in a future major release.
580
+ * Configure conditions that must be met before a pending update is applied.
581
+ *
582
+ * After calling {@link next} to queue an update, use this method to control when it gets applied.
583
+ * The update will only be installed after ALL specified conditions are satisfied.
584
+ *
585
+ * Available condition types:
586
+ * - `background`: Wait for the app to be backgrounded. Optionally specify duration in milliseconds.
587
+ * - `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.)
588
+ * - `date`: Wait until a specific date/time (ISO 8601 format)
589
+ * - `nativeVersion`: Wait until the native app is updated to a specific version
590
+ *
591
+ * Condition value formats:
592
+ * - `background`: Number in milliseconds (e.g., `"300000"` for 5 minutes), or omit for immediate
593
+ * - `kill`: No value needed
594
+ * - `date`: ISO 8601 date string (e.g., `"2025-12-31T23:59:59Z"`)
595
+ * - `nativeVersion`: Version string (e.g., `"2.0.0"`)
429
596
  *
430
597
  * @example
431
- * // Delay the update after the user kills the app or after a background of 300000 ms (5 minutes)
432
- * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'kill' }, { kind: 'background', value: '300000' }] })
598
+ * // Update after user kills app OR after 5 minutes in background
599
+ * await CapacitorUpdater.setMultiDelay({
600
+ * delayConditions: [
601
+ * { kind: 'kill' },
602
+ * { kind: 'background', value: '300000' }
603
+ * ]
604
+ * });
605
+ *
433
606
  * @example
434
- * // Delay the update after the specific iso8601 date is expired
435
- * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'date', value: '2022-09-14T06:14:11.920Z' }] })
607
+ * // Update after a specific date
608
+ * await CapacitorUpdater.setMultiDelay({
609
+ * delayConditions: [{ kind: 'date', value: '2025-12-31T23:59:59Z' }]
610
+ * });
611
+ *
436
612
  * @example
437
- * // Delay the update after the first background (default behaviour without setting delay)
438
- * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'background' }] })
439
- * @param options Containing the {@link MultiDelayConditions} array of conditions to set
440
- * @returns {Promise<void>}
441
- * @throws {Error}
613
+ * // Default behavior: update on next background
614
+ * await CapacitorUpdater.setMultiDelay({
615
+ * delayConditions: [{ kind: 'background' }]
616
+ * });
617
+ *
618
+ * @param options Contains the {@link MultiDelayConditions} array of conditions.
619
+ * @returns {Promise<void>} Resolves when the delay conditions are set.
620
+ * @throws {Error} If the operation fails or conditions are invalid.
442
621
  * @since 4.3.0
443
622
  */
444
623
  setMultiDelay(options: MultiDelayConditions): Promise<void>;
445
624
  /**
446
- * Cancels a {@link DelayCondition} to process an update immediately.
625
+ * Cancel all delay conditions and apply the pending update immediately.
626
+ *
627
+ * If you've set delay conditions with {@link setMultiDelay}, this method clears them
628
+ * and triggers the pending update to be applied on the next app background or restart.
447
629
  *
448
- * @returns {Promise<void>}
449
- * @throws {Error}
630
+ * This is useful when:
631
+ * - User manually requests to update now (e.g., clicks "Update now" button)
632
+ * - Your app detects it's a good time to update (e.g., user finished critical task)
633
+ * - You want to override a time-based delay early
634
+ *
635
+ * @returns {Promise<void>} Resolves when the delay conditions are cleared.
636
+ * @throws {Error} If the operation fails.
450
637
  * @since 4.0.0
451
638
  */
452
639
  cancelDelay(): Promise<void>;
453
640
  /**
454
- * Get Latest bundle available from update Url
641
+ * Check the update server for the latest available bundle version.
642
+ *
643
+ * This queries your configured update URL (or Capgo backend) to see if a newer bundle
644
+ * is available for download. It does NOT download the bundle automatically.
455
645
  *
456
- * @returns {Promise<LatestVersion>} A Promise resolved when url is loaded
457
- * @throws {Error}
646
+ * The response includes:
647
+ * - `version`: The latest available version identifier
648
+ * - `url`: Download URL for the bundle (if available)
649
+ * - `breaking`: Whether this update is marked as incompatible (requires native app update)
650
+ * - `message`: Optional message from the server
651
+ * - `manifest`: File list for partial updates (if using multi-file downloads)
652
+ *
653
+ * After receiving the latest version info, you can:
654
+ * 1. Compare it with your current version
655
+ * 2. Download it using {@link download}
656
+ * 3. Apply it using {@link next} or {@link set}
657
+ *
658
+ * @param options Optional {@link GetLatestOptions} to specify which channel to check.
659
+ * @returns {Promise<LatestVersion>} Information about the latest available bundle version.
660
+ * @throws {Error} If the request fails or the server returns an error.
458
661
  * @since 4.0.0
459
662
  */
460
663
  getLatest(options?: GetLatestOptions): Promise<LatestVersion>;
461
664
  /**
462
- * Sets the channel for this device. The channel has to allow for self assignment for this to work.
463
- * Do not use this method to set the channel at boot.
464
- * This method is to set the channel after the app is ready, and user interacted.
465
- * If you want to set the channel at boot, use the {@link PluginsConfig} to set the default channel.
466
- * This methods send to Capgo backend a request to link the device ID to the channel. Capgo can accept or refuse depending of the setting of your channel.
665
+ * Assign this device to a specific update channel at runtime.
666
+ *
667
+ * Channels allow you to distribute different bundle versions to different groups of users
668
+ * (e.g., "production", "beta", "staging"). This method switches the device to a new channel.
467
669
  *
670
+ * **Requirements:**
671
+ * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)
672
+ * - The backend may accept or reject the request based on channel settings
468
673
  *
674
+ * **When to use:**
675
+ * - After the app is ready and the user has interacted (e.g., opted into beta program)
676
+ * - To implement in-app channel switching (beta toggle, tester access, etc.)
677
+ * - For user-driven channel changes
469
678
  *
470
- * @param options Is the {@link SetChannelOptions} channel to set
471
- * @returns {Promise<ChannelRes>} A Promise which is resolved when the new channel is set
472
- * @throws {Error}
679
+ * **When NOT to use:**
680
+ * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead
681
+ * - Before user interaction
682
+ *
683
+ * This sends a request to the Capgo backend linking your device ID to the specified channel.
684
+ *
685
+ * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.
686
+ * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.
687
+ * @throws {Error} If the channel doesn't exist or doesn't allow self-assignment.
473
688
  * @since 4.7.0
474
689
  */
475
690
  setChannel(options: SetChannelOptions): Promise<ChannelRes>;
476
691
  /**
477
- * Unset the channel for this device. The device will then return to the default channel
692
+ * Remove the device's channel assignment and return to the default channel.
693
+ *
694
+ * This unlinks the device from any specifically assigned channel, causing it to fall back to:
695
+ * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or
696
+ * - Your backend's default channel for this app
478
697
  *
479
- * @returns {Promise<ChannelRes>} A Promise resolved when channel is set
480
- * @throws {Error}
698
+ * Use this when:
699
+ * - Users opt out of beta/testing programs
700
+ * - You want to reset a device to standard update distribution
701
+ * - Testing channel switching behavior
702
+ *
703
+ * @param options {@link UnsetChannelOptions} containing optional auto-update trigger.
704
+ * @returns {Promise<void>} Resolves when the channel is successfully unset.
705
+ * @throws {Error} If the operation fails.
481
706
  * @since 4.7.0
482
707
  */
483
708
  unsetChannel(options: UnsetChannelOptions): Promise<void>;
484
709
  /**
485
- * Get the channel for this device
710
+ * Get the current channel assigned to this device.
711
+ *
712
+ * Returns information about:
713
+ * - `channel`: The currently assigned channel name (if any)
714
+ * - `allowSet`: Whether the channel allows self-assignment
715
+ * - `status`: Operation status
716
+ * - `error`/`message`: Additional information (if applicable)
717
+ *
718
+ * Use this to:
719
+ * - Display current channel to users (e.g., "You're on the Beta channel")
720
+ * - Check if a device is on a specific channel before showing features
721
+ * - Verify channel assignment after calling {@link setChannel}
486
722
  *
487
- * @returns {Promise<ChannelRes>} A Promise that resolves with the channel info
488
- * @throws {Error}
723
+ * @returns {Promise<GetChannelRes>} The current channel information.
724
+ * @throws {Error} If the operation fails.
489
725
  * @since 4.8.0
490
726
  */
491
727
  getChannel(): Promise<GetChannelRes>;
492
728
  /**
493
- * List all channels available for this device that allow self-assignment
729
+ * Get a list of all channels available for this device to self-assign to.
494
730
  *
495
- * @returns {Promise<ListChannelsResult>} A Promise that resolves with the available channels
496
- * @throws {Error}
731
+ * Only returns channels where `allow_self_set` is `true`. These are channels that
732
+ * users can switch to using {@link setChannel} without backend administrator intervention.
733
+ *
734
+ * Each channel includes:
735
+ * - `id`: Unique channel identifier
736
+ * - `name`: Human-readable channel name
737
+ * - `public`: Whether the channel is publicly visible
738
+ * - `allow_self_set`: Always `true` in results (filtered to only self-assignable channels)
739
+ *
740
+ * Use this to:
741
+ * - Build a channel selector UI for users (e.g., "Join Beta" button)
742
+ * - Show available testing/preview channels
743
+ * - Implement channel discovery features
744
+ *
745
+ * @returns {Promise<ListChannelsResult>} List of channels the device can self-assign to.
746
+ * @throws {Error} If the operation fails or the request to the backend fails.
497
747
  * @since 7.5.0
498
748
  */
499
749
  listChannels(): Promise<ListChannelsResult>;
500
750
  /**
501
- * Set a custom ID for this device
751
+ * Set a custom identifier for this device.
752
+ *
753
+ * This allows you to identify devices by your own custom ID (user ID, account ID, etc.)
754
+ * instead of or in addition to the device's unique hardware ID. The custom ID is sent
755
+ * to your update server and can be used for:
756
+ * - Targeting specific users for updates
757
+ * - Analytics and user tracking
758
+ * - Debugging and support (correlating devices with users)
759
+ * - A/B testing or feature flagging
502
760
  *
503
- * When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is true, the value will be stored natively and restored on the next app launch.
504
- * Pass an empty string to remove any previously stored customId.
761
+ * **Persistence:**
762
+ * - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true`, the ID persists across app restarts
763
+ * - When `false`, the ID is only kept for the current session
505
764
  *
506
- * @param options is the {@link SetCustomIdOptions} customId to set
507
- * @returns {Promise<void>} an Promise resolved instantly
508
- * @throws {Error}
765
+ * **Clearing the custom ID:**
766
+ * - Pass an empty string `""` to remove any stored custom ID
767
+ *
768
+ * @param options The {@link SetCustomIdOptions} containing the custom identifier string.
769
+ * @returns {Promise<void>} Resolves immediately (synchronous operation).
770
+ * @throws {Error} If the operation fails.
509
771
  * @since 4.9.0
510
772
  */
511
773
  setCustomId(options: SetCustomIdOptions): Promise<void>;
512
774
  /**
513
- * Get the native app version or the builtin version if set in config
775
+ * Get the builtin bundle version (the original version shipped with your native app).
776
+ *
777
+ * This returns the version of the bundle that was included when the app was installed
778
+ * from the App Store or Play Store. This is NOT the currently active bundle version -
779
+ * use {@link current} for that.
780
+ *
781
+ * Returns:
782
+ * - The {@link PluginsConfig.CapacitorUpdater.version} config value if set, or
783
+ * - The native app version from platform configs (package.json, Info.plist, build.gradle)
514
784
  *
515
- * @returns {Promise<BuiltinVersion>} A Promise with version for this device
785
+ * Use this to:
786
+ * - Display the "factory" version to users
787
+ * - Compare against downloaded bundle versions
788
+ * - Determine if any updates have been applied
789
+ * - Debugging version mismatches
790
+ *
791
+ * @returns {Promise<BuiltinVersion>} The builtin bundle version string.
516
792
  * @since 5.2.0
517
793
  */
518
794
  getBuiltinVersion(): Promise<BuiltinVersion>;
519
795
  /**
520
- * Get unique ID used to identify device (sent to auto update server).
796
+ * Get the unique, privacy-friendly identifier for this device.
797
+ *
798
+ * This ID is used to identify the device when communicating with update servers.
799
+ * It's automatically generated and stored securely by the plugin.
800
+ *
801
+ * **Privacy & Security characteristics:**
802
+ * - Generated as a UUID (not based on hardware identifiers)
803
+ * - Stored securely in platform-specific secure storage
804
+ * - Android: Android Keystore (persists across app reinstalls on API 23+)
805
+ * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`
806
+ * - Not synced to cloud (iOS)
807
+ * - Follows Apple and Google privacy best practices
808
+ * - Users can clear it via system settings (Android) or keychain access (iOS)
521
809
  *
522
- * This ID is privacy-friendly and follows Apple and Google best practices:
523
- * - Generated as a UUID and stored securely
524
- * - Android: Uses Android Keystore (persists across reinstalls on API 23+)
525
- * - iOS: Uses Keychain with kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly (persists across reinstalls)
526
- * - Data stays on device (not synced to cloud on iOS)
527
- * - Can be cleared by user via system settings (Android) or keychain access (iOS)
810
+ * **Persistence:**
811
+ * The device ID persists across app reinstalls to maintain consistent device identity
812
+ * for update tracking and analytics.
528
813
  *
529
- * The device ID now persists between app reinstalls to maintain consistent device identity.
814
+ * Use this to:
815
+ * - Debug update delivery issues (check what ID the server sees)
816
+ * - Implement device-specific features
817
+ * - Correlate server logs with specific devices
530
818
  *
531
- * @returns {Promise<DeviceId>} A Promise with id for this device
532
- * @throws {Error}
819
+ * @returns {Promise<DeviceId>} The unique device identifier string.
820
+ * @throws {Error} If the operation fails.
533
821
  */
534
822
  getDeviceId(): Promise<DeviceId>;
535
823
  /**
536
- * Get the native Capacitor Updater plugin version (sent to auto update server)
824
+ * Get the version of the Capacitor Updater plugin installed in your app.
537
825
  *
538
- * @returns {Promise<PluginVersion>} A Promise with Plugin version
539
- * @throws {Error}
826
+ * This returns the version of the native plugin code (Android/iOS), which is sent
827
+ * to the update server with each request. This is NOT your app version or bundle version.
828
+ *
829
+ * Use this to:
830
+ * - Debug plugin-specific issues (when reporting bugs)
831
+ * - Verify plugin installation and version
832
+ * - Check compatibility with backend features
833
+ * - Display in debug/about screens
834
+ *
835
+ * @returns {Promise<PluginVersion>} The Capacitor Updater plugin version string.
836
+ * @throws {Error} If the operation fails.
540
837
  */
541
838
  getPluginVersion(): Promise<PluginVersion>;
542
839
  /**
543
- * Get the state of auto update config.
840
+ * Check if automatic updates are currently enabled.
841
+ *
842
+ * Returns `true` if {@link PluginsConfig.CapacitorUpdater.autoUpdate} is enabled,
843
+ * meaning the plugin will automatically check for, download, and apply updates.
544
844
  *
545
- * @returns {Promise<AutoUpdateEnabled>} The status for auto update. Evaluates to `false` in manual mode.
546
- * @throws {Error}
845
+ * Returns `false` if in manual mode, where you control the update flow using
846
+ * {@link getLatest}, {@link download}, {@link next}, and {@link set}.
847
+ *
848
+ * Use this to:
849
+ * - Determine which update flow your app is using
850
+ * - Show/hide manual update UI based on mode
851
+ * - Debug update behavior
852
+ *
853
+ * @returns {Promise<AutoUpdateEnabled>} `true` if auto-update is enabled, `false` if in manual mode.
854
+ * @throws {Error} If the operation fails.
547
855
  */
548
856
  isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;
549
857
  /**
550
- * Remove all listeners for this plugin.
858
+ * Remove all event listeners registered for this plugin.
859
+ *
860
+ * This unregisters all listeners added via {@link addListener} for all event types:
861
+ * - `download`
862
+ * - `noNeedUpdate`
863
+ * - `updateAvailable`
864
+ * - `downloadComplete`
865
+ * - `downloadFailed`
866
+ * - `breakingAvailable` / `majorAvailable`
867
+ * - `updateFailed`
868
+ * - `appReloaded`
869
+ * - `appReady`
870
+ *
871
+ * Use this during cleanup (e.g., when unmounting components or closing screens)
872
+ * to prevent memory leaks from lingering event listeners.
551
873
  *
874
+ * @returns {Promise<void>} Resolves when all listeners are removed.
552
875
  * @since 1.0.0
553
876
  */
554
877
  removeAllListeners(): Promise<void>;
@@ -616,60 +939,150 @@ export interface CapacitorUpdaterPlugin {
616
939
  */
617
940
  addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;
618
941
  /**
619
- * Get if auto update is available (not disabled by serverUrl).
942
+ * Check if the auto-update feature is available (not disabled by custom server configuration).
943
+ *
944
+ * Returns `false` when a custom `updateUrl` is configured, as this typically indicates
945
+ * you're using a self-hosted update server that may not support all auto-update features.
946
+ *
947
+ * Returns `true` when using the default Capgo backend or when the feature is available.
948
+ *
949
+ * This is different from {@link isAutoUpdateEnabled}:
950
+ * - `isAutoUpdateEnabled()`: Checks if auto-update MODE is turned on/off
951
+ * - `isAutoUpdateAvailable()`: Checks if auto-update is SUPPORTED with your current configuration
620
952
  *
621
- * @returns {Promise<AutoUpdateAvailable>} The availability status for auto update. Evaluates to `false` when serverUrl is set.
622
- * @throws {Error}
953
+ * @returns {Promise<AutoUpdateAvailable>} `false` when custom updateUrl is set, `true` otherwise.
954
+ * @throws {Error} If the operation fails.
623
955
  */
624
956
  isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;
625
957
  /**
626
- * Get the next bundle that will be used when the app reloads.
627
- * Returns null if no next bundle is set.
958
+ * Get information about the bundle queued to be activated on next reload.
628
959
  *
629
- * @returns {Promise<BundleInfo | null>} A Promise that resolves with the next bundle information or null
630
- * @throws {Error}
960
+ * Returns:
961
+ * - {@link BundleInfo} object if a bundle has been queued via {@link next}
962
+ * - `null` if no update is pending
963
+ *
964
+ * This is useful to:
965
+ * - Check if an update is waiting to be applied
966
+ * - Display "Update pending" status to users
967
+ * - Show version info of the queued update
968
+ * - Decide whether to show a "Restart to update" prompt
969
+ *
970
+ * The queued bundle will be activated when:
971
+ * - The app is backgrounded (default behavior)
972
+ * - The app is killed and restarted
973
+ * - {@link reload} is called manually
974
+ * - Delay conditions set by {@link setMultiDelay} are met
975
+ *
976
+ * @returns {Promise<BundleInfo | null>} The pending bundle info, or `null` if none is queued.
977
+ * @throws {Error} If the operation fails.
631
978
  * @since 6.8.0
632
979
  */
633
980
  getNextBundle(): Promise<BundleInfo | null>;
634
981
  /**
635
- * Get the most recent update that failed to install, if any. The stored value is cleared after it is retrieved once.
982
+ * Retrieve information about the most recent bundle that failed to load.
983
+ *
984
+ * When a bundle fails to load (e.g., JavaScript errors prevent initialization, missing files),
985
+ * the plugin automatically rolls back and stores information about the failure. This method
986
+ * retrieves that failure information.
987
+ *
988
+ * **IMPORTANT: The stored value is cleared after being retrieved once.**
989
+ * Calling this method multiple times will only return the failure info on the first call,
990
+ * then `null` on subsequent calls until another failure occurs.
991
+ *
992
+ * Returns:
993
+ * - {@link UpdateFailedEvent} with bundle info if a failure was recorded
994
+ * - `null` if no failure has occurred or if it was already retrieved
636
995
  *
637
- * @returns {Promise<UpdateFailedEvent | null>} The last failed update or null when no failure has been recorded. Value is cleared after it is returned once.
638
- * @throws {Error}
996
+ * Use this to:
997
+ * - Show users why an update failed
998
+ * - Log failure information for debugging
999
+ * - Implement custom error handling/reporting
1000
+ * - Display rollback notifications
1001
+ *
1002
+ * @returns {Promise<UpdateFailedEvent | null>} The failed update info (cleared after first retrieval), or `null`.
1003
+ * @throws {Error} If the operation fails.
639
1004
  * @since 7.22.0
640
1005
  */
641
1006
  getFailedUpdate(): Promise<UpdateFailedEvent | null>;
642
1007
  /**
643
- * Enable or disable the shake menu for debugging/testing purposes
1008
+ * Enable or disable the shake gesture menu for debugging and testing.
1009
+ *
1010
+ * When enabled, users can shake their device to open a debug menu that shows:
1011
+ * - Current bundle information
1012
+ * - Available bundles
1013
+ * - Options to switch bundles manually
1014
+ * - Update status
1015
+ *
1016
+ * This is useful during development and testing to:
1017
+ * - Quickly test different bundle versions
1018
+ * - Debug update flows
1019
+ * - Switch between production and test bundles
1020
+ * - Verify bundle installations
644
1021
  *
645
- * @param options Contains enabled boolean to enable or disable shake menu
646
- * @returns {Promise<void>}
647
- * @throws {Error}
1022
+ * **Important:** Disable this in production builds or only enable for internal testers.
1023
+ *
1024
+ * Can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1025
+ *
1026
+ * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.
1027
+ * @returns {Promise<void>} Resolves when the setting is applied.
1028
+ * @throws {Error} If the operation fails.
648
1029
  * @since 7.5.0
649
1030
  */
650
1031
  setShakeMenu(options: SetShakeMenuOptions): Promise<void>;
651
1032
  /**
652
- * Get the current state of the shake menu
1033
+ * Check if the shake gesture debug menu is currently enabled.
1034
+ *
1035
+ * Returns the current state of the shake menu feature that can be toggled via
1036
+ * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
653
1037
  *
654
- * @returns {Promise<ShakeMenuEnabled>} The current state of shake menu
655
- * @throws {Error}
1038
+ * Use this to:
1039
+ * - Check if debug features are enabled
1040
+ * - Show/hide debug settings UI
1041
+ * - Verify configuration during testing
1042
+ *
1043
+ * @returns {Promise<ShakeMenuEnabled>} Object with `enabled: true` or `enabled: false`.
1044
+ * @throws {Error} If the operation fails.
656
1045
  * @since 7.5.0
657
1046
  */
658
1047
  isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;
659
1048
  /**
660
- * Get the configured App ID
1049
+ * Get the currently configured App ID used for update server communication.
1050
+ *
1051
+ * Returns the App ID that identifies this app to the update server. This can be:
1052
+ * - The value set via {@link setAppId}, or
1053
+ * - The {@link PluginsConfig.CapacitorUpdater.appId} config value, or
1054
+ * - The default app identifier from your native app configuration
1055
+ *
1056
+ * Use this to:
1057
+ * - Verify which App ID is being used for updates
1058
+ * - Debug update delivery issues
1059
+ * - Display app configuration in debug screens
1060
+ * - Confirm App ID after calling {@link setAppId}
661
1061
  *
662
- * @returns {Promise<GetAppIdRes>} The current App ID
663
- * @throws {Error}
1062
+ * @returns {Promise<GetAppIdRes>} Object containing the current `appId` string.
1063
+ * @throws {Error} If the operation fails.
664
1064
  * @since 7.14.0
665
1065
  */
666
1066
  getAppId(): Promise<GetAppIdRes>;
667
1067
  /**
668
- * Set the App ID for the app (requires allowModifyAppId to be true in config)
1068
+ * Dynamically change the App ID used for update server communication.
1069
+ *
1070
+ * This overrides the App ID used to identify your app to the update server, allowing you
1071
+ * to switch between different app configurations at runtime (e.g., production vs staging
1072
+ * app IDs, or multi-tenant configurations).
1073
+ *
1074
+ * **Requirements:**
1075
+ * - {@link PluginsConfig.CapacitorUpdater.allowModifyAppId} must be set to `true`
1076
+ *
1077
+ * **Important considerations:**
1078
+ * - Changing the App ID will affect which updates this device receives
1079
+ * - The new App ID must exist on your update server
1080
+ * - This is primarily for advanced use cases (multi-tenancy, environment switching)
1081
+ * - Most apps should use the config-based {@link PluginsConfig.CapacitorUpdater.appId} instead
669
1082
  *
670
- * @param options The new App ID to set
671
- * @returns {Promise<void>}
672
- * @throws {Error} If allowModifyAppId is false or if the operation fails
1083
+ * @param options {@link SetAppIdOptions} containing the new App ID string.
1084
+ * @returns {Promise<void>} Resolves when the App ID is successfully changed.
1085
+ * @throws {Error} If `allowModifyAppId` is false or the operation fails.
673
1086
  * @since 7.14.0
674
1087
  */
675
1088
  setAppId(options: SetAppIdOptions): Promise<void>;