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