@capgo/capacitor-updater 7.33.4 → 7.34.0

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.
package/README.md CHANGED
@@ -66,6 +66,14 @@ The most complete [documentation here](https://capgo.app/docs/).
66
66
  ## Community
67
67
  Join the [discord](https://discord.gg/VnYRvBfgA6) to get help.
68
68
 
69
+ ## Migration to v7.34
70
+
71
+ - **Channel storage change**: `setChannel()` now stores channel assignments locally on the device instead of in the cloud. This provides better offline support and reduces backend load.
72
+ - Channel assignments persist between app restarts
73
+ - Use `unsetChannel()` to clear the local assignment and revert to `defaultChannel`
74
+ - Old devices (< v7.34.0) will continue using cloud-based storage
75
+ - **New event**: Listen to the `channelPrivate` event to handle cases where a user tries to assign themselves to a private channel (one that doesn't allow self-assignment). See example in the `setChannel()` documentation above.
76
+
69
77
  ## Migration to v7
70
78
 
71
79
  - `privateKey` is not available anymore, it was used for the old encryption method. to migrate follow this guide : [https://capgo.app/docs/plugin/cloud-mode/getting-started/](https://capgo.app/docs/cli/migrations/encryption/)
@@ -271,6 +279,7 @@ CapacitorUpdater can be configured with these options:
271
279
  | **`allowManualBundleError`** | <code>boolean</code> | Allow marking bundles as errored from JavaScript while using manual update flows. When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`. | <code>false</code> | 7.20.0 |
272
280
  | **`persistCustomId`** | <code>boolean</code> | Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts. Only available for Android and iOS. | <code>false (will be true by default in a future major release v8.x.x)</code> | 7.17.3 |
273
281
  | **`persistModifyUrl`** | <code>boolean</code> | Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl}, {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts. Only available for Android and iOS. | <code>false</code> | 7.20.0 |
282
+ | **`allowSetDefaultChannel`** | <code>boolean</code> | Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel. When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`. | <code>true</code> | 7.34.0 |
274
283
  | **`defaultChannel`** | <code>string</code> | Set the default channel for the app in the config. Case sensitive. This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud. 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 | <code>undefined</code> | 5.5.0 |
275
284
  | **`appId`** | <code>string</code> | Configure the app id for the app in the config. | <code>undefined</code> | 6.0.0 |
276
285
  | **`keepUrlPathAfterReload`** | <code>boolean</code> | Configure the plugin to keep the URL path after a reload. WARNING: When a reload is triggered, 'window.history' will be cleared. | <code>false</code> | 6.8.0 |
@@ -313,6 +322,7 @@ In `capacitor.config.json`:
313
322
  "allowManualBundleError": undefined,
314
323
  "persistCustomId": undefined,
315
324
  "persistModifyUrl": undefined,
325
+ "allowSetDefaultChannel": undefined,
316
326
  "defaultChannel": undefined,
317
327
  "appId": undefined,
318
328
  "keepUrlPathAfterReload": undefined,
@@ -361,6 +371,7 @@ const config: CapacitorConfig = {
361
371
  allowManualBundleError: undefined,
362
372
  persistCustomId: undefined,
363
373
  persistModifyUrl: undefined,
374
+ allowSetDefaultChannel: undefined,
364
375
  defaultChannel: undefined,
365
376
  appId: undefined,
366
377
  keepUrlPathAfterReload: undefined,
@@ -416,6 +427,7 @@ export default config;
416
427
  * [`addListener('downloadFailed', ...)`](#addlistenerdownloadfailed-)
417
428
  * [`addListener('appReloaded', ...)`](#addlistenerappreloaded-)
418
429
  * [`addListener('appReady', ...)`](#addlistenerappready-)
430
+ * [`addListener('channelPrivate', ...)`](#addlistenerchannelprivate-)
419
431
  * [`isAutoUpdateAvailable()`](#isautoupdateavailable)
420
432
  * [`getNextBundle()`](#getnextbundle)
421
433
  * [`getFailedUpdate()`](#getfailedupdate)
@@ -926,6 +938,19 @@ Channels allow you to distribute different bundle versions to different groups o
926
938
  - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead
927
939
  - Before user interaction
928
940
 
941
+ **Important: Listen for the `channelPrivate` event**
942
+
943
+ When a user attempts to set a channel that doesn't allow device self-assignment, the method will
944
+ throw an error AND fire a {@link addListener}('channelPrivate') event. You should listen to this event
945
+ to provide appropriate feedback to users:
946
+
947
+ ```typescript
948
+ CapacitorUpdater.addListener('channelPrivate', (data) =&gt; {
949
+ console.warn(`Cannot access channel "${data.channel}": ${data.message}`);
950
+ // Show user-friendly message
951
+ });
952
+ ```
953
+
929
954
  This sends a request to the Capgo backend linking your device ID to the specified channel.
930
955
 
931
956
  | Param | Type | Description |
@@ -1390,6 +1415,31 @@ Listen for app ready event in the App, let you know when app is ready to use, th
1390
1415
  --------------------
1391
1416
 
1392
1417
 
1418
+ #### addListener('channelPrivate', ...)
1419
+
1420
+ ```typescript
1421
+ addListener(eventName: 'channelPrivate', listenerFunc: (state: ChannelPrivateEvent) => void) => Promise<PluginListenerHandle>
1422
+ ```
1423
+
1424
+ Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.
1425
+
1426
+ This event is useful for:
1427
+ - Informing users they don't have permission to switch to a specific channel
1428
+ - Implementing custom error handling for channel restrictions
1429
+ - Logging unauthorized channel access attempts
1430
+
1431
+ | Param | Type |
1432
+ | ------------------ | --------------------------------------------------------------------------------------- |
1433
+ | **`eventName`** | <code>'channelPrivate'</code> |
1434
+ | **`listenerFunc`** | <code>(state: <a href="#channelprivateevent">ChannelPrivateEvent</a>) =&gt; void</code> |
1435
+
1436
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
1437
+
1438
+ **Since:** 7.34.0
1439
+
1440
+ --------------------
1441
+
1442
+
1393
1443
  #### isAutoUpdateAvailable()
1394
1444
 
1395
1445
  ```typescript
@@ -1879,6 +1929,14 @@ If you don't use backend, you need to provide the URL and version of the bundle.
1879
1929
  | **`status`** | <code>string</code> | | |
1880
1930
 
1881
1931
 
1932
+ ##### ChannelPrivateEvent
1933
+
1934
+ | Prop | Type | Description | Since |
1935
+ | ------------- | ------------------- | ----------------------------------------------------------------------------------- | ------ |
1936
+ | **`channel`** | <code>string</code> | Emitted when attempting to set a channel that doesn't allow device self-assignment. | 7.34.0 |
1937
+ | **`message`** | <code>string</code> | | |
1938
+
1939
+
1882
1940
  ##### AutoUpdateAvailable
1883
1941
 
1884
1942
  | Prop | Type |
@@ -68,10 +68,11 @@ public class CapacitorUpdaterPlugin extends Plugin {
68
68
  private static final String UPDATE_URL_PREF_KEY = "CapacitorUpdater.updateUrl";
69
69
  private static final String STATS_URL_PREF_KEY = "CapacitorUpdater.statsUrl";
70
70
  private static final String CHANNEL_URL_PREF_KEY = "CapacitorUpdater.channelUrl";
71
+ private static final String DEFAULT_CHANNEL_PREF_KEY = "CapacitorUpdater.defaultChannel";
71
72
  private static final String[] BREAKING_EVENT_NAMES = { "breakingAvailable", "majorAvailable" };
72
73
  private static final String LAST_FAILED_BUNDLE_PREF_KEY = "CapacitorUpdater.lastFailedBundle";
73
74
 
74
- private final String pluginVersion = "7.33.4";
75
+ private final String pluginVersion = "7.34.0";
75
76
  private static final String DELAY_CONDITION_PREFERENCES = "";
76
77
 
77
78
  private SharedPreferences.Editor editor;
@@ -100,6 +101,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
100
101
  private Boolean onLaunchDirectUpdateUsed = false;
101
102
  Boolean shakeMenuEnabled = false;
102
103
  private Boolean allowManualBundleError = false;
104
+ private Boolean allowSetDefaultChannel = true;
103
105
 
104
106
  private Boolean isPreviousMainActivity = true;
105
107
 
@@ -301,6 +303,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
301
303
 
302
304
  this.persistCustomId = this.getConfig().getBoolean("persistCustomId", false);
303
305
  this.persistModifyUrl = this.getConfig().getBoolean("persistModifyUrl", false);
306
+ this.allowSetDefaultChannel = this.getConfig().getBoolean("allowSetDefaultChannel", true);
304
307
  this.implementation.publicKey = this.getConfig().getString("publicKey", "");
305
308
  this.implementation.statsUrl = this.getConfig().getString("statsUrl", statsUrlDefault);
306
309
  this.implementation.channelUrl = this.getConfig().getString("channelUrl", channelUrlDefault);
@@ -320,8 +323,21 @@ public class CapacitorUpdaterPlugin extends Plugin {
320
323
  }
321
324
  }
322
325
  }
326
+
327
+ // Load defaultChannel: first try from persistent storage (set via setChannel), then fall back to config
328
+ if (this.prefs.contains(DEFAULT_CHANNEL_PREF_KEY)) {
329
+ final String storedDefaultChannel = this.prefs.getString(DEFAULT_CHANNEL_PREF_KEY, "");
330
+ if (storedDefaultChannel != null && !storedDefaultChannel.isEmpty()) {
331
+ this.implementation.defaultChannel = storedDefaultChannel;
332
+ logger.info("Loaded persisted defaultChannel from setChannel()");
333
+ } else {
334
+ this.implementation.defaultChannel = this.getConfig().getString("defaultChannel", "");
335
+ }
336
+ } else {
337
+ this.implementation.defaultChannel = this.getConfig().getString("defaultChannel", "");
338
+ }
339
+
323
340
  int userValue = this.getConfig().getInt("periodCheckDelay", 0);
324
- this.implementation.defaultChannel = this.getConfig().getString("defaultChannel", "");
325
341
 
326
342
  if (userValue >= 0 && userValue <= 600) {
327
343
  this.periodCheckDelay = 600 * 1000;
@@ -863,27 +879,33 @@ public class CapacitorUpdaterPlugin extends Plugin {
863
879
 
864
880
  try {
865
881
  logger.info("unsetChannel triggerAutoUpdate: " + triggerAutoUpdate);
866
- startNewThread(() ->
867
- CapacitorUpdaterPlugin.this.implementation.unsetChannel((res) -> {
868
- JSObject jsRes = mapToJSObject(res);
869
- if (jsRes.has("error")) {
870
- String errorMessage = jsRes.has("message") ? jsRes.getString("message") : jsRes.getString("error");
871
- String errorCode = jsRes.getString("error");
872
-
873
- JSObject errorObj = new JSObject();
874
- errorObj.put("message", errorMessage);
875
- errorObj.put("error", errorCode);
876
-
877
- call.reject(errorMessage, "UNSETCHANNEL_FAILED", null, errorObj);
878
- } else {
879
- if (CapacitorUpdaterPlugin.this._isAutoUpdateEnabled() && Boolean.TRUE.equals(triggerAutoUpdate)) {
880
- logger.info("Calling autoupdater after channel change!");
881
- backgroundDownload();
882
+ startNewThread(() -> {
883
+ String configDefaultChannel = CapacitorUpdaterPlugin.this.getConfig().getString("defaultChannel", "");
884
+ CapacitorUpdaterPlugin.this.implementation.unsetChannel(
885
+ CapacitorUpdaterPlugin.this.editor,
886
+ DEFAULT_CHANNEL_PREF_KEY,
887
+ configDefaultChannel,
888
+ (res) -> {
889
+ JSObject jsRes = mapToJSObject(res);
890
+ if (jsRes.has("error")) {
891
+ String errorMessage = jsRes.has("message") ? jsRes.getString("message") : jsRes.getString("error");
892
+ String errorCode = jsRes.getString("error");
893
+
894
+ JSObject errorObj = new JSObject();
895
+ errorObj.put("message", errorMessage);
896
+ errorObj.put("error", errorCode);
897
+
898
+ call.reject(errorMessage, "UNSETCHANNEL_FAILED", null, errorObj);
899
+ } else {
900
+ if (CapacitorUpdaterPlugin.this._isAutoUpdateEnabled() && Boolean.TRUE.equals(triggerAutoUpdate)) {
901
+ logger.info("Calling autoupdater after channel change!");
902
+ backgroundDownload();
903
+ }
904
+ call.resolve(jsRes);
882
905
  }
883
- call.resolve(jsRes);
884
906
  }
885
- })
886
- );
907
+ );
908
+ });
887
909
  } catch (final Exception e) {
888
910
  logger.error("Failed to unsetChannel: " + e.getMessage());
889
911
  call.reject("Failed to unsetChannel: ", e);
@@ -906,25 +928,42 @@ public class CapacitorUpdaterPlugin extends Plugin {
906
928
  try {
907
929
  logger.info("setChannel " + channel + " triggerAutoUpdate: " + triggerAutoUpdate);
908
930
  startNewThread(() ->
909
- CapacitorUpdaterPlugin.this.implementation.setChannel(channel, (res) -> {
910
- JSObject jsRes = mapToJSObject(res);
911
- if (jsRes.has("error")) {
912
- String errorMessage = jsRes.has("message") ? jsRes.getString("message") : jsRes.getString("error");
913
- String errorCode = jsRes.getString("error");
931
+ CapacitorUpdaterPlugin.this.implementation.setChannel(
932
+ channel,
933
+ CapacitorUpdaterPlugin.this.editor,
934
+ DEFAULT_CHANNEL_PREF_KEY,
935
+ CapacitorUpdaterPlugin.this.allowSetDefaultChannel,
936
+ (res) -> {
937
+ JSObject jsRes = mapToJSObject(res);
938
+ if (jsRes.has("error")) {
939
+ String errorMessage = jsRes.has("message") ? jsRes.getString("message") : jsRes.getString("error");
940
+ String errorCode = jsRes.getString("error");
941
+
942
+ // Fire channelPrivate event if channel doesn't allow self-assignment
943
+ if (
944
+ errorCode.contains("cannot_update_via_private_channel") ||
945
+ errorCode.contains("channel_self_set_not_allowed")
946
+ ) {
947
+ JSObject eventData = new JSObject();
948
+ eventData.put("channel", channel);
949
+ eventData.put("message", errorMessage);
950
+ notifyListeners("channelPrivate", eventData);
951
+ }
914
952
 
915
- JSObject errorObj = new JSObject();
916
- errorObj.put("message", errorMessage);
917
- errorObj.put("error", errorCode);
953
+ JSObject errorObj = new JSObject();
954
+ errorObj.put("message", errorMessage);
955
+ errorObj.put("error", errorCode);
918
956
 
919
- call.reject(errorMessage, "SETCHANNEL_FAILED", null, errorObj);
920
- } else {
921
- if (CapacitorUpdaterPlugin.this._isAutoUpdateEnabled() && Boolean.TRUE.equals(triggerAutoUpdate)) {
922
- logger.info("Calling autoupdater after channel change!");
923
- backgroundDownload();
957
+ call.reject(errorMessage, "SETCHANNEL_FAILED", null, errorObj);
958
+ } else {
959
+ if (CapacitorUpdaterPlugin.this._isAutoUpdateEnabled() && Boolean.TRUE.equals(triggerAutoUpdate)) {
960
+ logger.info("Calling autoupdater after channel change!");
961
+ backgroundDownload();
962
+ }
963
+ call.resolve(jsRes);
924
964
  }
925
- call.resolve(jsRes);
926
965
  }
927
- })
966
+ )
928
967
  );
929
968
  } catch (final Exception e) {
930
969
  logger.error("Failed to setChannel: " + channel + " " + e.getMessage());
@@ -968,115 +968,41 @@ public class CapgoUpdater {
968
968
  makeJsonRequest(updateUrl, json, callback);
969
969
  }
970
970
 
971
- public void unsetChannel(final Callback callback) {
972
- // Check if rate limit was exceeded
973
- if (rateLimitExceeded) {
974
- logger.debug("Skipping unsetChannel due to rate limit (429). Requests will resume after app restart.");
975
- final Map<String, Object> retError = new HashMap<>();
976
- retError.put("message", "Rate limit exceeded");
977
- retError.put("error", "rate_limit_exceeded");
978
- callback.callback(retError);
979
- return;
980
- }
971
+ public void unsetChannel(
972
+ final SharedPreferences.Editor editor,
973
+ final String defaultChannelKey,
974
+ final String configDefaultChannel,
975
+ final Callback callback
976
+ ) {
977
+ // Clear persisted defaultChannel and revert to config value
978
+ editor.remove(defaultChannelKey);
979
+ editor.apply();
980
+ this.defaultChannel = configDefaultChannel;
981
+ logger.info("Persisted defaultChannel cleared, reverted to config value: " + configDefaultChannel);
982
+
983
+ Map<String, Object> ret = new HashMap<>();
984
+ ret.put("status", "ok");
985
+ ret.put("message", "Channel override removed");
986
+ callback.callback(ret);
987
+ }
981
988
 
982
- String channelUrl = this.channelUrl;
983
- if (channelUrl == null || channelUrl.isEmpty()) {
984
- logger.error("Channel URL is not set");
985
- final Map<String, Object> retError = new HashMap<>();
986
- retError.put("message", "channelUrl missing");
987
- retError.put("error", "missing_config");
988
- callback.callback(retError);
989
- return;
990
- }
991
- JSONObject json;
992
- try {
993
- json = this.createInfoObject();
994
- } catch (JSONException e) {
995
- logger.error("Error unsetChannel JSONException " + e.getMessage());
989
+ public void setChannel(
990
+ final String channel,
991
+ final SharedPreferences.Editor editor,
992
+ final String defaultChannelKey,
993
+ final boolean allowSetDefaultChannel,
994
+ final Callback callback
995
+ ) {
996
+ // Check if setting defaultChannel is allowed
997
+ if (!allowSetDefaultChannel) {
998
+ logger.error("setChannel is disabled by allowSetDefaultChannel config");
996
999
  final Map<String, Object> retError = new HashMap<>();
997
- retError.put("message", "Cannot get info: " + e);
998
- retError.put("error", "json_error");
1000
+ retError.put("message", "setChannel is disabled by configuration");
1001
+ retError.put("error", "disabled_by_config");
999
1002
  callback.callback(retError);
1000
1003
  return;
1001
1004
  }
1002
1005
 
1003
- Request request = new Request.Builder()
1004
- .url(channelUrl)
1005
- .delete(RequestBody.create(json.toString(), MediaType.get("application/json")))
1006
- .build();
1007
-
1008
- DownloadService.sharedClient
1009
- .newCall(request)
1010
- .enqueue(
1011
- new okhttp3.Callback() {
1012
- @Override
1013
- public void onFailure(@NonNull Call call, @NonNull IOException e) {
1014
- Map<String, Object> retError = new HashMap<>();
1015
- retError.put("message", "Request failed: " + e.getMessage());
1016
- retError.put("error", "network_error");
1017
- callback.callback(retError);
1018
- }
1019
-
1020
- @Override
1021
- public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
1022
- try (ResponseBody responseBody = response.body()) {
1023
- // Check for 429 rate limit
1024
- if (checkAndHandleRateLimitResponse(response)) {
1025
- Map<String, Object> retError = new HashMap<>();
1026
- retError.put("message", "Rate limit exceeded");
1027
- retError.put("error", "rate_limit_exceeded");
1028
- callback.callback(retError);
1029
- return;
1030
- }
1031
-
1032
- if (!response.isSuccessful()) {
1033
- Map<String, Object> retError = new HashMap<>();
1034
- retError.put("message", "Server error: " + response.code());
1035
- retError.put("error", "response_error");
1036
- callback.callback(retError);
1037
- return;
1038
- }
1039
-
1040
- assert responseBody != null;
1041
- String responseData = responseBody.string();
1042
- JSONObject jsonResponse = new JSONObject(responseData);
1043
-
1044
- // Check for server-side errors first
1045
- if (jsonResponse.has("error")) {
1046
- Map<String, Object> retError = new HashMap<>();
1047
- retError.put("error", jsonResponse.getString("error"));
1048
- if (jsonResponse.has("message")) {
1049
- retError.put("message", jsonResponse.getString("message"));
1050
- } else {
1051
- retError.put("message", "server did not provide a message");
1052
- }
1053
- callback.callback(retError);
1054
- return;
1055
- }
1056
-
1057
- Map<String, Object> ret = new HashMap<>();
1058
-
1059
- Iterator<String> keys = jsonResponse.keys();
1060
- while (keys.hasNext()) {
1061
- String key = keys.next();
1062
- if (jsonResponse.has(key)) {
1063
- ret.put(key, jsonResponse.get(key));
1064
- }
1065
- }
1066
- logger.info("Channel unset");
1067
- callback.callback(ret);
1068
- } catch (JSONException e) {
1069
- Map<String, Object> retError = new HashMap<>();
1070
- retError.put("message", "JSON parse error: " + e.getMessage());
1071
- retError.put("error", "parse_error");
1072
- callback.callback(retError);
1073
- }
1074
- }
1075
- }
1076
- );
1077
- }
1078
-
1079
- public void setChannel(final String channel, final Callback callback) {
1080
1006
  // Check if rate limit was exceeded
1081
1007
  if (rateLimitExceeded) {
1082
1008
  logger.debug("Skipping setChannel due to rate limit (429). Requests will resume after app restart.");
@@ -1109,7 +1035,18 @@ public class CapgoUpdater {
1109
1035
  return;
1110
1036
  }
1111
1037
 
1112
- makeJsonRequest(channelUrl, json, callback);
1038
+ makeJsonRequest(channelUrl, json, (res) -> {
1039
+ if (res.containsKey("error")) {
1040
+ callback.callback(res);
1041
+ } else {
1042
+ // Success - persist defaultChannel
1043
+ this.defaultChannel = channel;
1044
+ editor.putString(defaultChannelKey, channel);
1045
+ editor.apply();
1046
+ logger.info("defaultChannel persisted locally: " + channel);
1047
+ callback.callback(res);
1048
+ }
1049
+ });
1113
1050
  }
1114
1051
 
1115
1052
  public void getChannel(final Callback callback) {
package/dist/docs.json CHANGED
@@ -535,7 +535,7 @@
535
535
  "text": "4.7.0"
536
536
  }
537
537
  ],
538
- "docs": "Assign this device to a specific update channel at runtime.\n\nChannels allow you to distribute different bundle versions to different groups of users\n(e.g., \"production\", \"beta\", \"staging\"). This method switches the device to a new channel.\n\n**Requirements:**\n- The target channel must allow self-assignment (configured in your Capgo dashboard or backend)\n- The backend may accept or reject the request based on channel settings\n\n**When to use:**\n- After the app is ready and the user has interacted (e.g., opted into beta program)\n- To implement in-app channel switching (beta toggle, tester access, etc.)\n- For user-driven channel changes\n\n**When NOT to use:**\n- At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead\n- Before user interaction\n\nThis sends a request to the Capgo backend linking your device ID to the specified channel.",
538
+ "docs": "Assign this device to a specific update channel at runtime.\n\nChannels allow you to distribute different bundle versions to different groups of users\n(e.g., \"production\", \"beta\", \"staging\"). This method switches the device to a new channel.\n\n**Requirements:**\n- The target channel must allow self-assignment (configured in your Capgo dashboard or backend)\n- The backend may accept or reject the request based on channel settings\n\n**When to use:**\n- After the app is ready and the user has interacted (e.g., opted into beta program)\n- To implement in-app channel switching (beta toggle, tester access, etc.)\n- For user-driven channel changes\n\n**When NOT to use:**\n- At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead\n- Before user interaction\n\n**Important: Listen for the `channelPrivate` event**\n\nWhen a user attempts to set a channel that doesn't allow device self-assignment, the method will\nthrow an error AND fire a {@link addListener}('channelPrivate') event. You should listen to this event\nto provide appropriate feedback to users:\n\n```typescript\nCapacitorUpdater.addListener('channelPrivate', (data) => {\n console.warn(`Cannot access channel \"${data.channel}\": ${data.message}`);\n // Show user-friendly message\n});\n```\n\nThis sends a request to the Capgo backend linking your device ID to the specified channel.",
539
539
  "complexTypes": [
540
540
  "ChannelRes",
541
541
  "SetChannelOptions"
@@ -1062,6 +1062,35 @@
1062
1062
  ],
1063
1063
  "slug": "addlistenerappready-"
1064
1064
  },
1065
+ {
1066
+ "name": "addListener",
1067
+ "signature": "(eventName: 'channelPrivate', listenerFunc: (state: ChannelPrivateEvent) => void) => Promise<PluginListenerHandle>",
1068
+ "parameters": [
1069
+ {
1070
+ "name": "eventName",
1071
+ "docs": "",
1072
+ "type": "'channelPrivate'"
1073
+ },
1074
+ {
1075
+ "name": "listenerFunc",
1076
+ "docs": "",
1077
+ "type": "(state: ChannelPrivateEvent) => void"
1078
+ }
1079
+ ],
1080
+ "returns": "Promise<PluginListenerHandle>",
1081
+ "tags": [
1082
+ {
1083
+ "name": "since",
1084
+ "text": "7.34.0"
1085
+ }
1086
+ ],
1087
+ "docs": "Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.\n\nThis event is useful for:\n- Informing users they don't have permission to switch to a specific channel\n- Implementing custom error handling for channel restrictions\n- Logging unauthorized channel access attempts",
1088
+ "complexTypes": [
1089
+ "PluginListenerHandle",
1090
+ "ChannelPrivateEvent"
1091
+ ],
1092
+ "slug": "addlistenerchannelprivate-"
1093
+ },
1065
1094
  {
1066
1095
  "name": "isAutoUpdateAvailable",
1067
1096
  "signature": "() => Promise<AutoUpdateAvailable>",
@@ -2260,6 +2289,34 @@
2260
2289
  }
2261
2290
  ]
2262
2291
  },
2292
+ {
2293
+ "name": "ChannelPrivateEvent",
2294
+ "slug": "channelprivateevent",
2295
+ "docs": "",
2296
+ "tags": [],
2297
+ "methods": [],
2298
+ "properties": [
2299
+ {
2300
+ "name": "channel",
2301
+ "tags": [
2302
+ {
2303
+ "text": "7.34.0",
2304
+ "name": "since"
2305
+ }
2306
+ ],
2307
+ "docs": "Emitted when attempting to set a channel that doesn't allow device self-assignment.",
2308
+ "complexTypes": [],
2309
+ "type": "string"
2310
+ },
2311
+ {
2312
+ "name": "message",
2313
+ "tags": [],
2314
+ "docs": "",
2315
+ "complexTypes": [],
2316
+ "type": "string"
2317
+ }
2318
+ ]
2319
+ },
2263
2320
  {
2264
2321
  "name": "AutoUpdateAvailable",
2265
2322
  "slug": "autoupdateavailable",
@@ -2860,6 +2917,22 @@
2860
2917
  "complexTypes": [],
2861
2918
  "type": "boolean | undefined"
2862
2919
  },
2920
+ {
2921
+ "name": "allowSetDefaultChannel",
2922
+ "tags": [
2923
+ {
2924
+ "text": "true",
2925
+ "name": "default"
2926
+ },
2927
+ {
2928
+ "text": "7.34.0",
2929
+ "name": "since"
2930
+ }
2931
+ ],
2932
+ "docs": "Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel.\nWhen set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.",
2933
+ "complexTypes": [],
2934
+ "type": "boolean | undefined"
2935
+ },
2863
2936
  {
2864
2937
  "name": "defaultChannel",
2865
2938
  "tags": [
@@ -268,6 +268,14 @@ declare module '@capacitor/cli' {
268
268
  * @since 7.20.0
269
269
  */
270
270
  persistModifyUrl?: boolean;
271
+ /**
272
+ * Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel.
273
+ * When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.
274
+ *
275
+ * @default true
276
+ * @since 7.34.0
277
+ */
278
+ allowSetDefaultChannel?: boolean;
271
279
  /**
272
280
  * Set the default channel for the app in the config. Case sensitive.
273
281
  * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.
@@ -708,6 +716,19 @@ export interface CapacitorUpdaterPlugin {
708
716
  * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead
709
717
  * - Before user interaction
710
718
  *
719
+ * **Important: Listen for the `channelPrivate` event**
720
+ *
721
+ * When a user attempts to set a channel that doesn't allow device self-assignment, the method will
722
+ * throw an error AND fire a {@link addListener}('channelPrivate') event. You should listen to this event
723
+ * to provide appropriate feedback to users:
724
+ *
725
+ * ```typescript
726
+ * CapacitorUpdater.addListener('channelPrivate', (data) => {
727
+ * console.warn(`Cannot access channel "${data.channel}": ${data.message}`);
728
+ * // Show user-friendly message
729
+ * });
730
+ * ```
731
+ *
711
732
  * This sends a request to the Capgo backend linking your device ID to the specified channel.
712
733
  *
713
734
  * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.
@@ -966,6 +987,17 @@ export interface CapacitorUpdaterPlugin {
966
987
  * @since 5.1.0
967
988
  */
968
989
  addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;
990
+ /**
991
+ * Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.
992
+ *
993
+ * This event is useful for:
994
+ * - Informing users they don't have permission to switch to a specific channel
995
+ * - Implementing custom error handling for channel restrictions
996
+ * - Logging unauthorized channel access attempts
997
+ *
998
+ * @since 7.34.0
999
+ */
1000
+ addListener(eventName: 'channelPrivate', listenerFunc: (state: ChannelPrivateEvent) => void): Promise<PluginListenerHandle>;
969
1001
  /**
970
1002
  * Check if the auto-update feature is available (not disabled by custom server configuration).
971
1003
  *
@@ -1252,6 +1284,15 @@ export interface AppReadyEvent {
1252
1284
  bundle: BundleInfo;
1253
1285
  status: string;
1254
1286
  }
1287
+ export interface ChannelPrivateEvent {
1288
+ /**
1289
+ * Emitted when attempting to set a channel that doesn't allow device self-assignment.
1290
+ *
1291
+ * @since 7.34.0
1292
+ */
1293
+ channel: string;
1294
+ message: string;
1295
+ }
1255
1296
  export interface ManifestEntry {
1256
1297
  file_name: string | null;
1257
1298
  file_hash: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n\n/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * CapacitorUpdater can be configured with these options:\n */\n CapacitorUpdater?: {\n /**\n * Configure the number of milliseconds the native plugin should wait before considering an update 'failed'.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @example 1000 // (1 second)\n */\n appReadyTimeout?: number;\n /**\n * Configure the number of seconds the native plugin should wait before considering API timeout.\n *\n * Only available for Android and iOS.\n *\n * @default 20 // (20 second)\n * @example 10 // (10 second)\n */\n responseTimeout?: number;\n /**\n * Configure whether the plugin should use automatically delete failed bundles.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeleteFailed?: boolean;\n\n /**\n * Configure whether the plugin should use automatically delete previous bundles after a successful update.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeletePrevious?: boolean;\n\n /**\n * Configure whether the plugin should use Auto Update via an update server.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoUpdate?: boolean;\n\n /**\n * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n resetWhenUpdate?: boolean;\n\n /**\n * Configure the URL / endpoint to which update checks are sent.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/updates\n * @example https://example.com/api/auto_update\n */\n updateUrl?: string;\n\n /**\n * Configure the URL / endpoint for channel operations.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/channel_self\n * @example https://example.com/api/channel\n */\n channelUrl?: string;\n\n /**\n * Configure the URL / endpoint to which update statistics are sent.\n *\n * Only available for Android and iOS. Set to \"\" to disable stats reporting.\n *\n * @default https://plugin.capgo.app/stats\n * @example https://example.com/api/stats\n */\n statsUrl?: string;\n /**\n * Configure the public key for end to end live update encryption Version 2\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 6.2.0\n */\n publicKey?: string;\n\n /**\n * Configure the current version of the app. This will be used for the first update request.\n * If not set, the plugin will get the version from the native code.\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 4.17.48\n */\n version?: string;\n /**\n * Configure when the plugin should direct install updates. Only for autoUpdate mode.\n * Works well for apps less than 10MB and with uploads done using --partial flag.\n * Zip or apps more than 10MB will be relatively slow for users to update.\n * - false: Never do direct updates (use default behavior: download at start, set when backgrounded)\n * - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false\n * - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false\n * - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false\n * - true: (deprecated) Same as \"always\" for backward compatibility\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 5.1.0\n */\n directUpdate?: boolean | 'atInstall' | 'always' | 'onLaunch';\n\n /**\n * Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.\n * This removes the need to manually listen for appReady events and call SplashScreen.hide().\n * Only works when directUpdate is set to \"atInstall\", \"always\", \"onLaunch\", or true.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n * Requires autoUpdate and directUpdate to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.6.0\n */\n autoSplashscreen?: boolean;\n\n /**\n * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.\n * Only takes effect when {@link autoSplashscreen} is enabled.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.19.0\n */\n autoSplashscreenLoader?: boolean;\n\n /**\n * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.\n * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.\n * Set to `0` (zero) to disable the timeout.\n * When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.\n * Requires {@link autoSplashscreen} to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @since 7.19.0\n */\n autoSplashscreenTimeout?: number;\n\n /**\n * Configure the delay period for period update check. the unit is in seconds.\n *\n * Only available for Android and iOS.\n * Cannot be less than 600 seconds (10 minutes).\n *\n * @default 0 (disabled)\n * @example 3600 (1 hour)\n * @example 86400 (24 hours)\n */\n periodCheckDelay?: number;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localS3?: boolean;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localHost?: string;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localWebHost?: string;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupa?: string;\n /**\n * Configure the CLI to use a local server for testing.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupaAnon?: string;\n /**\n * Configure the CLI to use a local api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApi?: string;\n /**\n * Configure the CLI to use a local file api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApiFiles?: string;\n /**\n * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 5.4.0\n */\n allowModifyUrl?: boolean;\n\n /**\n * Allow the plugin to modify the appId dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 7.14.0\n */\n allowModifyAppId?: boolean;\n\n /**\n * Allow marking bundles as errored from JavaScript while using manual update flows.\n * When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`.\n *\n * @default false\n * @since 7.20.0\n */\n allowManualBundleError?: boolean;\n\n /**\n * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false (will be true by default in a future major release v8.x.x)\n * @since 7.17.3\n */\n persistCustomId?: boolean;\n\n /**\n * Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl},\n * {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.20.0\n */\n persistModifyUrl?: boolean;\n\n /**\n * Set the default channel for the app in the config. Case sensitive.\n * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.\n * 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\n *\n *\n * @default undefined\n * @since 5.5.0\n */\n defaultChannel?: string;\n /**\n * Configure the app id for the app in the config.\n *\n * @default undefined\n * @since 6.0.0\n */\n appId?: string;\n\n /**\n * Configure the plugin to keep the URL path after a reload.\n * WARNING: When a reload is triggered, 'window.history' will be cleared.\n *\n * @default false\n * @since 6.8.0\n */\n keepUrlPathAfterReload?: boolean;\n /**\n * 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\n *\n * @default false\n * @since 7.3.0\n */\n disableJSLogging?: boolean;\n /**\n * Enable shake gesture to show update menu for debugging/testing purposes\n *\n * @default false\n * @since 7.5.0\n */\n shakeMenu?: boolean;\n };\n }\n}\n\nexport interface CapacitorUpdaterPlugin {\n /**\n * Notify the native layer that JavaScript initialized successfully.\n *\n * **CRITICAL: You must call this method on every app launch to prevent automatic rollback.**\n *\n * This is a simple notification to confirm that your bundle's JavaScript loaded and executed.\n * The native web server successfully served the bundle files and your JS runtime started.\n * That's all it checks - nothing more complex.\n *\n * **What triggers rollback:**\n * - NOT calling this method within the timeout (default: 10 seconds)\n * - Complete JavaScript failure (bundle won't load at all)\n *\n * **What does NOT trigger rollback:**\n * - Runtime errors after initialization (API failures, crashes, etc.)\n * - Network request failures\n * - Application logic errors\n *\n * **IMPORTANT: Call this BEFORE any network requests.**\n * Don't wait for APIs, data loading, or async operations. Call it as soon as your\n * JavaScript bundle starts executing to confirm the bundle itself is valid.\n *\n * Best practices:\n * - Call immediately in your app entry point (main.js, app component mount, etc.)\n * - Don't put it after network calls or heavy initialization\n * - Don't wrap it in try/catch with conditions\n * - Adjust {@link PluginsConfig.CapacitorUpdater.appReadyTimeout} if you need more time\n *\n * @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.\n */\n notifyAppReady(): Promise<AppReadyResult>;\n\n /**\n * Set the update URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.updateUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n * Otherwise, the URL will reset to the config value on next app launch.\n *\n * @param options Contains the URL to use for checking for updates.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setUpdateUrl(options: UpdateUrl): Promise<void>;\n\n /**\n * Set the statistics URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.statsUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Pass an empty string to disable statistics gathering entirely.\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n *\n * @param options Contains the URL to use for sending statistics, or an empty string to disable.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setStatsUrl(options: StatsUrl): Promise<void>;\n\n /**\n * Set the channel URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.channelUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n * Otherwise, the URL will reset to the config value on next app launch.\n *\n * @param options Contains the URL to use for channel operations.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setChannelUrl(options: ChannelUrl): Promise<void>;\n\n /**\n * Download a new bundle from the provided URL for later installation.\n *\n * The downloaded bundle is stored locally but not activated. To use it:\n * - Call {@link next} to set it for installation on next app backgrounding/restart\n * - Call {@link set} to activate it immediately (destroys current JavaScript context)\n *\n * The URL should point to a zip file containing either:\n * - Your app files directly in the zip root, or\n * - A single folder containing all your app files\n *\n * The bundle must include an `index.html` file at the root level.\n *\n * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.\n * For multi-file partial updates, provide the `manifest` array.\n *\n * @example\n * const bundle = await CapacitorUpdater.download({\n * url: `https://example.com/versions/${version}/dist.zip`,\n * version: version\n * });\n * // Bundle is downloaded but not active yet\n * await CapacitorUpdater.next({ id: bundle.id }); // Will activate on next background\n *\n * @param options The {@link DownloadOptions} for downloading a new bundle zip.\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the downloaded bundle.\n * @throws {Error} If the download fails or the bundle is invalid.\n */\n download(options: DownloadOptions): Promise<BundleInfo>;\n\n /**\n * Set the next bundle to be activated when the app backgrounds or restarts.\n *\n * This is the recommended way to apply updates as it doesn't interrupt the user's current session.\n * The bundle will be activated when:\n * - The app is backgrounded (user switches away), or\n * - The app is killed and relaunched, or\n * - {@link reload} is called manually\n *\n * Unlike {@link set}, this method does NOT destroy the current JavaScript context immediately.\n * Your app continues running normally until one of the above events occurs.\n *\n * Use {@link setMultiDelay} to add additional conditions before the update is applied.\n *\n * @param options Contains the ID of the bundle to set as next. Use {@link BundleInfo.id} from a downloaded bundle.\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.\n * @throws {Error} When there is no index.html file inside the bundle folder or the bundle doesn't exist.\n */\n next(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Set the current bundle and immediately reloads the app.\n *\n * **IMPORTANT: This is a terminal operation that destroys the current JavaScript context.**\n *\n * When you call this method:\n * - The entire JavaScript context is immediately destroyed\n * - The app reloads from a different folder with different files\n * - NO code after this call will execute\n * - NO promises will resolve\n * - NO callbacks will fire\n * - Event listeners registered after this call are unreliable and may never fire\n *\n * The reload happens automatically - you don't need to do anything else.\n * If you need to preserve state like the current URL path, use the {@link PluginsConfig.CapacitorUpdater.keepUrlPathAfterReload} config option.\n * For other state preservation needs, save your data before calling this method (e.g., to localStorage).\n *\n * **Do not** try to execute additional logic after calling `set()` - it won't work as expected.\n *\n * @param options A {@link BundleId} object containing the new bundle id to set as current.\n * @returns {Promise<void>} A promise that will never resolve because the JavaScript context is destroyed.\n * @throws {Error} When there is no index.html file inside the bundle folder.\n */\n set(options: BundleId): Promise<void>;\n\n /**\n * Delete a bundle from local storage to free up disk space.\n *\n * You cannot delete:\n * - The currently active bundle\n * - The `builtin` bundle (the version shipped with your app)\n * - The bundle set as `next` (call {@link next} with a different bundle first)\n *\n * Use {@link list} to get all available bundle IDs.\n *\n * **Note:** The bundle ID is NOT the same as the version name.\n * Use the `id` field from {@link BundleInfo}, not the `version` field.\n *\n * @param options A {@link BundleId} object containing the bundle ID to delete.\n * @returns {Promise<void>} Resolves when the bundle is successfully deleted.\n * @throws {Error} If the bundle is currently in use or doesn't exist.\n */\n delete(options: BundleId): Promise<void>;\n\n /**\n * Manually mark a bundle as failed/errored in manual update mode.\n *\n * This is useful when you detect that a bundle has critical issues and want to prevent\n * it from being used again. The bundle status will be changed to `error` and the plugin\n * will avoid using this bundle in the future.\n *\n * **Requirements:**\n * - {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} must be set to `true`\n * - Only works in manual update mode (when autoUpdate is disabled)\n *\n * Common use case: After downloading and testing a bundle, you discover it has critical\n * bugs and want to mark it as failed so it won't be retried.\n *\n * @param options A {@link BundleId} object containing the bundle ID to mark as errored.\n * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} with status set to `error`.\n * @throws {Error} When the bundle does not exist or `allowManualBundleError` is false.\n * @since 7.20.0\n */\n setBundleError(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Get all locally downloaded bundles stored in your app.\n *\n * This returns all bundles that have been downloaded and are available locally, including:\n * - The currently active bundle\n * - The `builtin` bundle (shipped with your app)\n * - Any downloaded bundles waiting to be activated\n * - Failed bundles (with `error` status)\n *\n * Use this to:\n * - Check available disk space by counting bundles\n * - Delete old bundles with {@link delete}\n * - Monitor bundle download status\n *\n * @param options The {@link ListOptions} for customizing the bundle list output.\n * @returns {Promise<BundleListResult>} A promise containing the array of {@link BundleInfo} objects.\n * @throws {Error} If the operation fails.\n */\n list(options?: ListOptions): Promise<BundleListResult>;\n\n /**\n * Reset the app to a known good bundle.\n *\n * This method helps recover from problematic updates by reverting to either:\n * - The `builtin` bundle (the original version shipped with your app to App Store/Play Store)\n * - The last successfully loaded bundle (most recent bundle that worked correctly)\n *\n * **IMPORTANT: This triggers an immediate app reload, destroying the current JavaScript context.**\n * See {@link set} for details on the implications of this operation.\n *\n * Use cases:\n * - Emergency recovery when an update causes critical issues\n * - Testing rollback functionality\n * - Providing users a \"reset to factory\" option\n *\n * @param options {@link ResetOptions} to control reset behavior. If `toLastSuccessful` is `false` (or omitted), resets to builtin. If `true`, resets to last successful bundle.\n * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.\n * @throws {Error} If the reset operation fails.\n */\n reset(options?: ResetOptions): Promise<void>;\n\n /**\n * Get information about the currently active bundle.\n *\n * Returns:\n * - `bundle`: The currently active bundle information\n * - `native`: The version of the builtin bundle (the original app version from App/Play Store)\n *\n * If no updates have been applied, `bundle.id` will be `\"builtin\"`, indicating the app\n * is running the original version shipped with the native app.\n *\n * Use this to:\n * - Display the current version to users\n * - Check if an update is currently active\n * - Compare against available updates\n * - Log the active bundle for debugging\n *\n * @returns {Promise<CurrentBundleResult>} A promise with the current bundle and native version info.\n * @throws {Error} If the operation fails.\n */\n current(): Promise<CurrentBundleResult>;\n\n /**\n * Manually reload the app to apply a pending update.\n *\n * This triggers the same reload behavior that happens automatically when the app backgrounds.\n * If you've called {@link next} to queue an update, calling `reload()` will apply it immediately.\n *\n * **IMPORTANT: This destroys the current JavaScript context immediately.**\n * See {@link set} for details on the implications of this operation.\n *\n * Common use cases:\n * - Applying an update immediately after download instead of waiting for backgrounding\n * - Providing a \"Restart now\" button to users after an update is ready\n * - Testing update flows during development\n *\n * If no update is pending (no call to {@link next}), this simply reloads the current bundle.\n *\n * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.\n * @throws {Error} If the reload operation fails.\n */\n reload(): Promise<void>;\n\n /**\n * Configure conditions that must be met before a pending update is applied.\n *\n * After calling {@link next} to queue an update, use this method to control when it gets applied.\n * The update will only be installed after ALL specified conditions are satisfied.\n *\n * Available condition types:\n * - `background`: Wait for the app to be backgrounded. Optionally specify duration in milliseconds.\n * - `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.)\n * - `date`: Wait until a specific date/time (ISO 8601 format)\n * - `nativeVersion`: Wait until the native app is updated to a specific version\n *\n * Condition value formats:\n * - `background`: Number in milliseconds (e.g., `\"300000\"` for 5 minutes), or omit for immediate\n * - `kill`: No value needed\n * - `date`: ISO 8601 date string (e.g., `\"2025-12-31T23:59:59Z\"`)\n * - `nativeVersion`: Version string (e.g., `\"2.0.0\"`)\n *\n * @example\n * // Update after user kills app OR after 5 minutes in background\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [\n * { kind: 'kill' },\n * { kind: 'background', value: '300000' }\n * ]\n * });\n *\n * @example\n * // Update after a specific date\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [{ kind: 'date', value: '2025-12-31T23:59:59Z' }]\n * });\n *\n * @example\n * // Default behavior: update on next background\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [{ kind: 'background' }]\n * });\n *\n * @param options Contains the {@link MultiDelayConditions} array of conditions.\n * @returns {Promise<void>} Resolves when the delay conditions are set.\n * @throws {Error} If the operation fails or conditions are invalid.\n * @since 4.3.0\n */\n setMultiDelay(options: MultiDelayConditions): Promise<void>;\n\n /**\n * Cancel all delay conditions and apply the pending update immediately.\n *\n * If you've set delay conditions with {@link setMultiDelay}, this method clears them\n * and triggers the pending update to be applied on the next app background or restart.\n *\n * This is useful when:\n * - User manually requests to update now (e.g., clicks \"Update now\" button)\n * - Your app detects it's a good time to update (e.g., user finished critical task)\n * - You want to override a time-based delay early\n *\n * @returns {Promise<void>} Resolves when the delay conditions are cleared.\n * @throws {Error} If the operation fails.\n * @since 4.0.0\n */\n cancelDelay(): Promise<void>;\n\n /**\n * Check the update server for the latest available bundle version.\n *\n * This queries your configured update URL (or Capgo backend) to see if a newer bundle\n * is available for download. It does NOT download the bundle automatically.\n *\n * The response includes:\n * - `version`: The latest available version identifier\n * - `url`: Download URL for the bundle (if available)\n * - `breaking`: Whether this update is marked as incompatible (requires native app update)\n * - `message`: Optional message from the server\n * - `manifest`: File list for partial updates (if using multi-file downloads)\n *\n * After receiving the latest version info, you can:\n * 1. Compare it with your current version\n * 2. Download it using {@link download}\n * 3. Apply it using {@link next} or {@link set}\n *\n * **Important: Error handling for \"no new version available\"**\n *\n * When the device's current version matches the latest version on the server (i.e., the device is already\n * up-to-date), the server returns a 200 response with `error: \"no_new_version_available\"` and\n * `message: \"No new version available\"`. **This causes `getLatest()` to throw an error**, even though\n * this is a normal, expected condition.\n *\n * You should catch this specific error to handle it gracefully:\n *\n * ```typescript\n * try {\n * const latest = await CapacitorUpdater.getLatest();\n * // New version is available, proceed with download\n * } catch (error) {\n * if (error.message === 'No new version available') {\n * // Device is already on the latest version - this is normal\n * console.log('Already up to date');\n * } else {\n * // Actual error occurred\n * console.error('Failed to check for updates:', error);\n * }\n * }\n * ```\n *\n * In this scenario, the server:\n * - Logs the request with a \"No new version available\" message\n * - Sends a \"noNew\" stat action to track that the device checked for updates but was already current (done on the backend)\n *\n * @param options Optional {@link GetLatestOptions} to specify which channel to check.\n * @returns {Promise<LatestVersion>} Information about the latest available bundle version.\n * @throws {Error} Always throws when no new version is available (`error: \"no_new_version_available\"`), or when the request fails.\n * @since 4.0.0\n */\n getLatest(options?: GetLatestOptions): Promise<LatestVersion>;\n\n /**\n * Assign this device to a specific update channel at runtime.\n *\n * Channels allow you to distribute different bundle versions to different groups of users\n * (e.g., \"production\", \"beta\", \"staging\"). This method switches the device to a new channel.\n *\n * **Requirements:**\n * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)\n * - The backend may accept or reject the request based on channel settings\n *\n * **When to use:**\n * - After the app is ready and the user has interacted (e.g., opted into beta program)\n * - To implement in-app channel switching (beta toggle, tester access, etc.)\n * - For user-driven channel changes\n *\n * **When NOT to use:**\n * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead\n * - Before user interaction\n *\n * This sends a request to the Capgo backend linking your device ID to the specified channel.\n *\n * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.\n * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.\n * @throws {Error} If the channel doesn't exist or doesn't allow self-assignment.\n * @since 4.7.0\n */\n setChannel(options: SetChannelOptions): Promise<ChannelRes>;\n\n /**\n * Remove the device's channel assignment and return to the default channel.\n *\n * This unlinks the device from any specifically assigned channel, causing it to fall back to:\n * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or\n * - Your backend's default channel for this app\n *\n * Use this when:\n * - Users opt out of beta/testing programs\n * - You want to reset a device to standard update distribution\n * - Testing channel switching behavior\n *\n * @param options {@link UnsetChannelOptions} containing optional auto-update trigger.\n * @returns {Promise<void>} Resolves when the channel is successfully unset.\n * @throws {Error} If the operation fails.\n * @since 4.7.0\n */\n unsetChannel(options: UnsetChannelOptions): Promise<void>;\n\n /**\n * Get the current channel assigned to this device.\n *\n * Returns information about:\n * - `channel`: The currently assigned channel name (if any)\n * - `allowSet`: Whether the channel allows self-assignment\n * - `status`: Operation status\n * - `error`/`message`: Additional information (if applicable)\n *\n * Use this to:\n * - Display current channel to users (e.g., \"You're on the Beta channel\")\n * - Check if a device is on a specific channel before showing features\n * - Verify channel assignment after calling {@link setChannel}\n *\n * @returns {Promise<GetChannelRes>} The current channel information.\n * @throws {Error} If the operation fails.\n * @since 4.8.0\n */\n getChannel(): Promise<GetChannelRes>;\n\n /**\n * Get a list of all channels available for this device to self-assign to.\n *\n * Only returns channels where `allow_self_set` is `true`. These are channels that\n * users can switch to using {@link setChannel} without backend administrator intervention.\n *\n * Each channel includes:\n * - `id`: Unique channel identifier\n * - `name`: Human-readable channel name\n * - `public`: Whether the channel is publicly visible\n * - `allow_self_set`: Always `true` in results (filtered to only self-assignable channels)\n *\n * Use this to:\n * - Build a channel selector UI for users (e.g., \"Join Beta\" button)\n * - Show available testing/preview channels\n * - Implement channel discovery features\n *\n * @returns {Promise<ListChannelsResult>} List of channels the device can self-assign to.\n * @throws {Error} If the operation fails or the request to the backend fails.\n * @since 7.5.0\n */\n listChannels(): Promise<ListChannelsResult>;\n\n /**\n * Set a custom identifier for this device.\n *\n * This allows you to identify devices by your own custom ID (user ID, account ID, etc.)\n * instead of or in addition to the device's unique hardware ID. The custom ID is sent\n * to your update server and can be used for:\n * - Targeting specific users for updates\n * - Analytics and user tracking\n * - Debugging and support (correlating devices with users)\n * - A/B testing or feature flagging\n *\n * **Persistence:**\n * - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true`, the ID persists across app restarts\n * - When `false`, the ID is only kept for the current session\n *\n * **Clearing the custom ID:**\n * - Pass an empty string `\"\"` to remove any stored custom ID\n *\n * @param options The {@link SetCustomIdOptions} containing the custom identifier string.\n * @returns {Promise<void>} Resolves immediately (synchronous operation).\n * @throws {Error} If the operation fails.\n * @since 4.9.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n\n /**\n * Get the builtin bundle version (the original version shipped with your native app).\n *\n * This returns the version of the bundle that was included when the app was installed\n * from the App Store or Play Store. This is NOT the currently active bundle version -\n * use {@link current} for that.\n *\n * Returns:\n * - The {@link PluginsConfig.CapacitorUpdater.version} config value if set, or\n * - The native app version from platform configs (package.json, Info.plist, build.gradle)\n *\n * Use this to:\n * - Display the \"factory\" version to users\n * - Compare against downloaded bundle versions\n * - Determine if any updates have been applied\n * - Debugging version mismatches\n *\n * @returns {Promise<BuiltinVersion>} The builtin bundle version string.\n * @since 5.2.0\n */\n getBuiltinVersion(): Promise<BuiltinVersion>;\n\n /**\n * Get the unique, privacy-friendly identifier for this device.\n *\n * This ID is used to identify the device when communicating with update servers.\n * It's automatically generated and stored securely by the plugin.\n *\n * **Privacy & Security characteristics:**\n * - Generated as a UUID (not based on hardware identifiers)\n * - Stored securely in platform-specific secure storage\n * - Android: Android Keystore (persists across app reinstalls on API 23+)\n * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`\n * - Not synced to cloud (iOS)\n * - Follows Apple and Google privacy best practices\n * - Users can clear it via system settings (Android) or keychain access (iOS)\n *\n * **Persistence:**\n * The device ID persists across app reinstalls to maintain consistent device identity\n * for update tracking and analytics.\n *\n * Use this to:\n * - Debug update delivery issues (check what ID the server sees)\n * - Implement device-specific features\n * - Correlate server logs with specific devices\n *\n * @returns {Promise<DeviceId>} The unique device identifier string.\n * @throws {Error} If the operation fails.\n */\n getDeviceId(): Promise<DeviceId>;\n\n /**\n * Get the version of the Capacitor Updater plugin installed in your app.\n *\n * This returns the version of the native plugin code (Android/iOS), which is sent\n * to the update server with each request. This is NOT your app version or bundle version.\n *\n * Use this to:\n * - Debug plugin-specific issues (when reporting bugs)\n * - Verify plugin installation and version\n * - Check compatibility with backend features\n * - Display in debug/about screens\n *\n * @returns {Promise<PluginVersion>} The Capacitor Updater plugin version string.\n * @throws {Error} If the operation fails.\n */\n getPluginVersion(): Promise<PluginVersion>;\n\n /**\n * Check if automatic updates are currently enabled.\n *\n * Returns `true` if {@link PluginsConfig.CapacitorUpdater.autoUpdate} is enabled,\n * meaning the plugin will automatically check for, download, and apply updates.\n *\n * Returns `false` if in manual mode, where you control the update flow using\n * {@link getLatest}, {@link download}, {@link next}, and {@link set}.\n *\n * Use this to:\n * - Determine which update flow your app is using\n * - Show/hide manual update UI based on mode\n * - Debug update behavior\n *\n * @returns {Promise<AutoUpdateEnabled>} `true` if auto-update is enabled, `false` if in manual mode.\n * @throws {Error} If the operation fails.\n */\n isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;\n\n /**\n * Remove all event listeners registered for this plugin.\n *\n * This unregisters all listeners added via {@link addListener} for all event types:\n * - `download`\n * - `noNeedUpdate`\n * - `updateAvailable`\n * - `downloadComplete`\n * - `downloadFailed`\n * - `breakingAvailable` / `majorAvailable`\n * - `updateFailed`\n * - `appReloaded`\n * - `appReady`\n *\n * Use this during cleanup (e.g., when unmounting components or closing screens)\n * to prevent memory leaks from lingering event listeners.\n *\n * @returns {Promise<void>} Resolves when all listeners are removed.\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.\n * This will return you all download percent during the download\n *\n * @since 2.0.11\n */\n addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for no need to update event, useful when you want force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for available update event, useful when you want to force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'updateAvailable',\n listenerFunc: (state: UpdateAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for downloadComplete events.\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadComplete',\n listenerFunc: (state: DownloadCompleteEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for breaking update events when the backend flags an update as incompatible with the current app.\n * Emits the same payload as the legacy `majorAvailable` listener.\n *\n * @since 7.22.0\n */\n addListener(\n eventName: 'breakingAvailable',\n listenerFunc: (state: BreakingAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking\n *\n * @deprecated Deprecated alias for {@link addListener} with `breakingAvailable`. Emits the same payload. will be removed in v8\n * @since 2.3.0\n */\n addListener(\n eventName: 'majorAvailable',\n listenerFunc: (state: MajorAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for update fail event in the App, let you know when update has fail to install at next app start\n *\n * @since 2.3.0\n */\n addListener(\n eventName: 'updateFailed',\n listenerFunc: (state: UpdateFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for download fail event in the App, let you know when a bundle download has failed\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadFailed',\n listenerFunc: (state: DownloadFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for reload event in the App, let you know when reload has happened\n *\n * @since 4.3.0\n */\n addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for app ready event in the App, let you know when app is ready to use, this event is retain till consumed.\n *\n * @since 5.1.0\n */\n addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Check if the auto-update feature is available (not disabled by custom server configuration).\n *\n * Returns `false` when a custom `updateUrl` is configured, as this typically indicates\n * you're using a self-hosted update server that may not support all auto-update features.\n *\n * Returns `true` when using the default Capgo backend or when the feature is available.\n *\n * This is different from {@link isAutoUpdateEnabled}:\n * - `isAutoUpdateEnabled()`: Checks if auto-update MODE is turned on/off\n * - `isAutoUpdateAvailable()`: Checks if auto-update is SUPPORTED with your current configuration\n *\n * @returns {Promise<AutoUpdateAvailable>} `false` when custom updateUrl is set, `true` otherwise.\n * @throws {Error} If the operation fails.\n */\n isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;\n\n /**\n * Get information about the bundle queued to be activated on next reload.\n *\n * Returns:\n * - {@link BundleInfo} object if a bundle has been queued via {@link next}\n * - `null` if no update is pending\n *\n * This is useful to:\n * - Check if an update is waiting to be applied\n * - Display \"Update pending\" status to users\n * - Show version info of the queued update\n * - Decide whether to show a \"Restart to update\" prompt\n *\n * The queued bundle will be activated when:\n * - The app is backgrounded (default behavior)\n * - The app is killed and restarted\n * - {@link reload} is called manually\n * - Delay conditions set by {@link setMultiDelay} are met\n *\n * @returns {Promise<BundleInfo | null>} The pending bundle info, or `null` if none is queued.\n * @throws {Error} If the operation fails.\n * @since 6.8.0\n */\n getNextBundle(): Promise<BundleInfo | null>;\n\n /**\n * Retrieve information about the most recent bundle that failed to load.\n *\n * When a bundle fails to load (e.g., JavaScript errors prevent initialization, missing files),\n * the plugin automatically rolls back and stores information about the failure. This method\n * retrieves that failure information.\n *\n * **IMPORTANT: The stored value is cleared after being retrieved once.**\n * Calling this method multiple times will only return the failure info on the first call,\n * then `null` on subsequent calls until another failure occurs.\n *\n * Returns:\n * - {@link UpdateFailedEvent} with bundle info if a failure was recorded\n * - `null` if no failure has occurred or if it was already retrieved\n *\n * Use this to:\n * - Show users why an update failed\n * - Log failure information for debugging\n * - Implement custom error handling/reporting\n * - Display rollback notifications\n *\n * @returns {Promise<UpdateFailedEvent | null>} The failed update info (cleared after first retrieval), or `null`.\n * @throws {Error} If the operation fails.\n * @since 7.22.0\n */\n getFailedUpdate(): Promise<UpdateFailedEvent | null>;\n\n /**\n * Enable or disable the shake gesture menu for debugging and testing.\n *\n * When enabled, users can shake their device to open a debug menu that shows:\n * - Current bundle information\n * - Available bundles\n * - Options to switch bundles manually\n * - Update status\n *\n * This is useful during development and testing to:\n * - Quickly test different bundle versions\n * - Debug update flows\n * - Switch between production and test bundles\n * - Verify bundle installations\n *\n * **Important:** Disable this in production builds or only enable for internal testers.\n *\n * Can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.\n *\n * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.\n * @returns {Promise<void>} Resolves when the setting is applied.\n * @throws {Error} If the operation fails.\n * @since 7.5.0\n */\n setShakeMenu(options: SetShakeMenuOptions): Promise<void>;\n\n /**\n * Check if the shake gesture debug menu is currently enabled.\n *\n * Returns the current state of the shake menu feature that can be toggled via\n * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.\n *\n * Use this to:\n * - Check if debug features are enabled\n * - Show/hide debug settings UI\n * - Verify configuration during testing\n *\n * @returns {Promise<ShakeMenuEnabled>} Object with `enabled: true` or `enabled: false`.\n * @throws {Error} If the operation fails.\n * @since 7.5.0\n */\n isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;\n\n /**\n * Get the currently configured App ID used for update server communication.\n *\n * Returns the App ID that identifies this app to the update server. This can be:\n * - The value set via {@link setAppId}, or\n * - The {@link PluginsConfig.CapacitorUpdater.appId} config value, or\n * - The default app identifier from your native app configuration\n *\n * Use this to:\n * - Verify which App ID is being used for updates\n * - Debug update delivery issues\n * - Display app configuration in debug screens\n * - Confirm App ID after calling {@link setAppId}\n *\n * @returns {Promise<GetAppIdRes>} Object containing the current `appId` string.\n * @throws {Error} If the operation fails.\n * @since 7.14.0\n */\n getAppId(): Promise<GetAppIdRes>;\n\n /**\n * Dynamically change the App ID used for update server communication.\n *\n * This overrides the App ID used to identify your app to the update server, allowing you\n * to switch between different app configurations at runtime (e.g., production vs staging\n * app IDs, or multi-tenant configurations).\n *\n * **Requirements:**\n * - {@link PluginsConfig.CapacitorUpdater.allowModifyAppId} must be set to `true`\n *\n * **Important considerations:**\n * - Changing the App ID will affect which updates this device receives\n * - The new App ID must exist on your update server\n * - This is primarily for advanced use cases (multi-tenancy, environment switching)\n * - Most apps should use the config-based {@link PluginsConfig.CapacitorUpdater.appId} instead\n *\n * @param options {@link SetAppIdOptions} containing the new App ID string.\n * @returns {Promise<void>} Resolves when the App ID is successfully changed.\n * @throws {Error} If `allowModifyAppId` is false or the operation fails.\n * @since 7.14.0\n */\n setAppId(options: SetAppIdOptions): Promise<void>;\n}\n\n/**\n * pending: The bundle is pending to be **SET** as the next bundle.\n * downloading: The bundle is being downloaded.\n * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.\n * error: The bundle has failed to download.\n */\nexport type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';\n\nexport type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';\n\nexport interface NoNeedEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateAvailableEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface ChannelRes {\n /**\n * Current status of set channel\n *\n * @since 4.7.0\n */\n status: string;\n error?: string;\n message?: string;\n}\n\nexport interface GetChannelRes {\n /**\n * Current status of get channel\n *\n * @since 4.8.0\n */\n channel?: string;\n error?: string;\n message?: string;\n status?: string;\n allowSet?: boolean;\n}\n\nexport interface ChannelInfo {\n /**\n * The channel ID\n *\n * @since 7.5.0\n */\n id: string;\n /**\n * The channel name\n *\n * @since 7.5.0\n */\n name: string;\n /**\n * Whether this is a public channel\n *\n * @since 7.5.0\n */\n public: boolean;\n /**\n * Whether devices can self-assign to this channel\n *\n * @since 7.5.0\n */\n allow_self_set: boolean;\n}\n\nexport interface ListChannelsResult {\n /**\n * List of available channels\n *\n * @since 7.5.0\n */\n channels: ChannelInfo[];\n}\n\nexport interface DownloadEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n percent: number;\n bundle: BundleInfo;\n}\n\nexport interface MajorAvailableEvent {\n /**\n * Emit when a breaking update is available.\n *\n * @deprecated Deprecated alias for {@link BreakingAvailableEvent}. Receives the same payload.\n * @since 4.0.0\n */\n version: string;\n}\n\n/**\n * Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvailable`.\n *\n * @since 7.22.0\n */\nexport type BreakingAvailableEvent = MajorAvailableEvent;\n\nexport interface DownloadFailedEvent {\n /**\n * Emit when a download fail.\n *\n * @since 4.0.0\n */\n version: string;\n}\n\nexport interface DownloadCompleteEvent {\n /**\n * Emit when a new update is available.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateFailedEvent {\n /**\n * Emit when a update failed to install.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface AppReadyEvent {\n /**\n * Emitted when the app is ready to use.\n *\n * @since 5.2.0\n */\n bundle: BundleInfo;\n status: string;\n}\n\nexport interface ManifestEntry {\n file_name: string | null;\n file_hash: string | null;\n download_url: string | null;\n}\n\nexport interface LatestVersion {\n /**\n * Result of getLatest method\n *\n * @since 4.0.0\n */\n version: string;\n /**\n * @since 6\n */\n checksum?: string;\n /**\n * Indicates whether the update was flagged as breaking by the backend.\n *\n * @since 7.22.0\n */\n breaking?: boolean;\n /**\n * @deprecated Use {@link LatestVersion.breaking} instead.\n */\n major?: boolean;\n /**\n * Optional message from the server.\n * When no new version is available, this will be \"No new version available\".\n */\n message?: string;\n sessionKey?: string;\n /**\n * Error code from the server, if any.\n * Common values:\n * - `\"no_new_version_available\"`: Device is already on the latest version (not a failure)\n * - Other error codes indicate actual failures in the update process\n */\n error?: string;\n /**\n * The previous/current version name (provided for reference).\n */\n old?: string;\n /**\n * Download URL for the bundle (when a new version is available).\n */\n url?: string;\n /**\n * File list for partial updates (when using multi-file downloads).\n * @since 6.1\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleInfo {\n id: string;\n version: string;\n downloaded: string;\n checksum: string;\n status: BundleStatus;\n}\n\nexport interface SetChannelOptions {\n channel: string;\n triggerAutoUpdate?: boolean;\n}\n\nexport interface UnsetChannelOptions {\n triggerAutoUpdate?: boolean;\n}\n\nexport interface SetCustomIdOptions {\n /**\n * Custom identifier to associate with the device. Use an empty string to clear any saved value.\n */\n customId: string;\n}\n\nexport interface DelayCondition {\n /**\n * Set up delay conditions in setMultiDelay\n * @param value is useless for @param kind \"kill\", optional for \"background\" (default value: \"0\") and required for \"nativeVersion\" and \"date\"\n */\n kind: DelayUntilNext;\n value?: string;\n}\n\nexport interface GetLatestOptions {\n /**\n * The channel to get the latest version for\n * The channel must allow 'self_assign' for this to work\n * @since 6.8.0\n * @default undefined\n */\n channel?: string;\n}\n\nexport interface AppReadyResult {\n bundle: BundleInfo;\n}\n\nexport interface UpdateUrl {\n url: string;\n}\n\nexport interface StatsUrl {\n url: string;\n}\n\nexport interface ChannelUrl {\n url: string;\n}\n\n/**\n * 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.\n * 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.\n */\nexport interface DownloadOptions {\n /**\n * 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.)\n */\n url: string;\n /**\n * The version code/name of this bundle/version\n */\n version: string;\n /**\n * The session key for the update, when the bundle is encrypted with a session key\n * @since 4.0.0\n * @default undefined\n */\n sessionKey?: string;\n /**\n * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted\n * @since 4.0.0\n * @default undefined\n */\n checksum?: string;\n /**\n * The manifest for multi-file downloads\n * @since 6.1.0\n * @default undefined\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleId {\n id: string;\n}\n\nexport interface BundleListResult {\n bundles: BundleInfo[];\n}\n\nexport interface ResetOptions {\n toLastSuccessful: boolean;\n}\n\nexport interface ListOptions {\n /**\n * 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.\n * @since 6.14.0\n * @default false\n */\n raw?: boolean;\n}\n\nexport interface CurrentBundleResult {\n bundle: BundleInfo;\n native: string;\n}\n\nexport interface MultiDelayConditions {\n delayConditions: DelayCondition[];\n}\n\nexport interface BuiltinVersion {\n version: string;\n}\n\nexport interface DeviceId {\n deviceId: string;\n}\n\nexport interface PluginVersion {\n version: string;\n}\n\nexport interface AutoUpdateEnabled {\n enabled: boolean;\n}\n\nexport interface AutoUpdateAvailable {\n available: boolean;\n}\n\nexport interface SetShakeMenuOptions {\n enabled: boolean;\n}\n\nexport interface ShakeMenuEnabled {\n enabled: boolean;\n}\n\nexport interface GetAppIdRes {\n appId: string;\n}\n\nexport interface SetAppIdOptions {\n appId: string;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n\n/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * CapacitorUpdater can be configured with these options:\n */\n CapacitorUpdater?: {\n /**\n * Configure the number of milliseconds the native plugin should wait before considering an update 'failed'.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @example 1000 // (1 second)\n */\n appReadyTimeout?: number;\n /**\n * Configure the number of seconds the native plugin should wait before considering API timeout.\n *\n * Only available for Android and iOS.\n *\n * @default 20 // (20 second)\n * @example 10 // (10 second)\n */\n responseTimeout?: number;\n /**\n * Configure whether the plugin should use automatically delete failed bundles.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeleteFailed?: boolean;\n\n /**\n * Configure whether the plugin should use automatically delete previous bundles after a successful update.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeletePrevious?: boolean;\n\n /**\n * Configure whether the plugin should use Auto Update via an update server.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoUpdate?: boolean;\n\n /**\n * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n resetWhenUpdate?: boolean;\n\n /**\n * Configure the URL / endpoint to which update checks are sent.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/updates\n * @example https://example.com/api/auto_update\n */\n updateUrl?: string;\n\n /**\n * Configure the URL / endpoint for channel operations.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/channel_self\n * @example https://example.com/api/channel\n */\n channelUrl?: string;\n\n /**\n * Configure the URL / endpoint to which update statistics are sent.\n *\n * Only available for Android and iOS. Set to \"\" to disable stats reporting.\n *\n * @default https://plugin.capgo.app/stats\n * @example https://example.com/api/stats\n */\n statsUrl?: string;\n /**\n * Configure the public key for end to end live update encryption Version 2\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 6.2.0\n */\n publicKey?: string;\n\n /**\n * Configure the current version of the app. This will be used for the first update request.\n * If not set, the plugin will get the version from the native code.\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 4.17.48\n */\n version?: string;\n /**\n * Configure when the plugin should direct install updates. Only for autoUpdate mode.\n * Works well for apps less than 10MB and with uploads done using --partial flag.\n * Zip or apps more than 10MB will be relatively slow for users to update.\n * - false: Never do direct updates (use default behavior: download at start, set when backgrounded)\n * - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false\n * - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false\n * - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false\n * - true: (deprecated) Same as \"always\" for backward compatibility\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 5.1.0\n */\n directUpdate?: boolean | 'atInstall' | 'always' | 'onLaunch';\n\n /**\n * Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.\n * This removes the need to manually listen for appReady events and call SplashScreen.hide().\n * Only works when directUpdate is set to \"atInstall\", \"always\", \"onLaunch\", or true.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n * Requires autoUpdate and directUpdate to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.6.0\n */\n autoSplashscreen?: boolean;\n\n /**\n * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.\n * Only takes effect when {@link autoSplashscreen} is enabled.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.19.0\n */\n autoSplashscreenLoader?: boolean;\n\n /**\n * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.\n * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.\n * Set to `0` (zero) to disable the timeout.\n * When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.\n * Requires {@link autoSplashscreen} to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @since 7.19.0\n */\n autoSplashscreenTimeout?: number;\n\n /**\n * Configure the delay period for period update check. the unit is in seconds.\n *\n * Only available for Android and iOS.\n * Cannot be less than 600 seconds (10 minutes).\n *\n * @default 0 (disabled)\n * @example 3600 (1 hour)\n * @example 86400 (24 hours)\n */\n periodCheckDelay?: number;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localS3?: boolean;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localHost?: string;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localWebHost?: string;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupa?: string;\n /**\n * Configure the CLI to use a local server for testing.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupaAnon?: string;\n /**\n * Configure the CLI to use a local api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApi?: string;\n /**\n * Configure the CLI to use a local file api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApiFiles?: string;\n /**\n * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 5.4.0\n */\n allowModifyUrl?: boolean;\n\n /**\n * Allow the plugin to modify the appId dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 7.14.0\n */\n allowModifyAppId?: boolean;\n\n /**\n * Allow marking bundles as errored from JavaScript while using manual update flows.\n * When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`.\n *\n * @default false\n * @since 7.20.0\n */\n allowManualBundleError?: boolean;\n\n /**\n * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false (will be true by default in a future major release v8.x.x)\n * @since 7.17.3\n */\n persistCustomId?: boolean;\n\n /**\n * Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl},\n * {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.20.0\n */\n persistModifyUrl?: boolean;\n\n /**\n * Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel.\n * When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.\n *\n * @default true\n * @since 7.34.0\n */\n allowSetDefaultChannel?: boolean;\n\n /**\n * Set the default channel for the app in the config. Case sensitive.\n * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.\n * 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\n *\n *\n * @default undefined\n * @since 5.5.0\n */\n defaultChannel?: string;\n /**\n * Configure the app id for the app in the config.\n *\n * @default undefined\n * @since 6.0.0\n */\n appId?: string;\n\n /**\n * Configure the plugin to keep the URL path after a reload.\n * WARNING: When a reload is triggered, 'window.history' will be cleared.\n *\n * @default false\n * @since 6.8.0\n */\n keepUrlPathAfterReload?: boolean;\n /**\n * 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\n *\n * @default false\n * @since 7.3.0\n */\n disableJSLogging?: boolean;\n /**\n * Enable shake gesture to show update menu for debugging/testing purposes\n *\n * @default false\n * @since 7.5.0\n */\n shakeMenu?: boolean;\n };\n }\n}\n\nexport interface CapacitorUpdaterPlugin {\n /**\n * Notify the native layer that JavaScript initialized successfully.\n *\n * **CRITICAL: You must call this method on every app launch to prevent automatic rollback.**\n *\n * This is a simple notification to confirm that your bundle's JavaScript loaded and executed.\n * The native web server successfully served the bundle files and your JS runtime started.\n * That's all it checks - nothing more complex.\n *\n * **What triggers rollback:**\n * - NOT calling this method within the timeout (default: 10 seconds)\n * - Complete JavaScript failure (bundle won't load at all)\n *\n * **What does NOT trigger rollback:**\n * - Runtime errors after initialization (API failures, crashes, etc.)\n * - Network request failures\n * - Application logic errors\n *\n * **IMPORTANT: Call this BEFORE any network requests.**\n * Don't wait for APIs, data loading, or async operations. Call it as soon as your\n * JavaScript bundle starts executing to confirm the bundle itself is valid.\n *\n * Best practices:\n * - Call immediately in your app entry point (main.js, app component mount, etc.)\n * - Don't put it after network calls or heavy initialization\n * - Don't wrap it in try/catch with conditions\n * - Adjust {@link PluginsConfig.CapacitorUpdater.appReadyTimeout} if you need more time\n *\n * @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.\n */\n notifyAppReady(): Promise<AppReadyResult>;\n\n /**\n * Set the update URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.updateUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n * Otherwise, the URL will reset to the config value on next app launch.\n *\n * @param options Contains the URL to use for checking for updates.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setUpdateUrl(options: UpdateUrl): Promise<void>;\n\n /**\n * Set the statistics URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.statsUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Pass an empty string to disable statistics gathering entirely.\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n *\n * @param options Contains the URL to use for sending statistics, or an empty string to disable.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setStatsUrl(options: StatsUrl): Promise<void>;\n\n /**\n * Set the channel URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.channelUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n * Otherwise, the URL will reset to the config value on next app launch.\n *\n * @param options Contains the URL to use for channel operations.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setChannelUrl(options: ChannelUrl): Promise<void>;\n\n /**\n * Download a new bundle from the provided URL for later installation.\n *\n * The downloaded bundle is stored locally but not activated. To use it:\n * - Call {@link next} to set it for installation on next app backgrounding/restart\n * - Call {@link set} to activate it immediately (destroys current JavaScript context)\n *\n * The URL should point to a zip file containing either:\n * - Your app files directly in the zip root, or\n * - A single folder containing all your app files\n *\n * The bundle must include an `index.html` file at the root level.\n *\n * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.\n * For multi-file partial updates, provide the `manifest` array.\n *\n * @example\n * const bundle = await CapacitorUpdater.download({\n * url: `https://example.com/versions/${version}/dist.zip`,\n * version: version\n * });\n * // Bundle is downloaded but not active yet\n * await CapacitorUpdater.next({ id: bundle.id }); // Will activate on next background\n *\n * @param options The {@link DownloadOptions} for downloading a new bundle zip.\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the downloaded bundle.\n * @throws {Error} If the download fails or the bundle is invalid.\n */\n download(options: DownloadOptions): Promise<BundleInfo>;\n\n /**\n * Set the next bundle to be activated when the app backgrounds or restarts.\n *\n * This is the recommended way to apply updates as it doesn't interrupt the user's current session.\n * The bundle will be activated when:\n * - The app is backgrounded (user switches away), or\n * - The app is killed and relaunched, or\n * - {@link reload} is called manually\n *\n * Unlike {@link set}, this method does NOT destroy the current JavaScript context immediately.\n * Your app continues running normally until one of the above events occurs.\n *\n * Use {@link setMultiDelay} to add additional conditions before the update is applied.\n *\n * @param options Contains the ID of the bundle to set as next. Use {@link BundleInfo.id} from a downloaded bundle.\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.\n * @throws {Error} When there is no index.html file inside the bundle folder or the bundle doesn't exist.\n */\n next(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Set the current bundle and immediately reloads the app.\n *\n * **IMPORTANT: This is a terminal operation that destroys the current JavaScript context.**\n *\n * When you call this method:\n * - The entire JavaScript context is immediately destroyed\n * - The app reloads from a different folder with different files\n * - NO code after this call will execute\n * - NO promises will resolve\n * - NO callbacks will fire\n * - Event listeners registered after this call are unreliable and may never fire\n *\n * The reload happens automatically - you don't need to do anything else.\n * If you need to preserve state like the current URL path, use the {@link PluginsConfig.CapacitorUpdater.keepUrlPathAfterReload} config option.\n * For other state preservation needs, save your data before calling this method (e.g., to localStorage).\n *\n * **Do not** try to execute additional logic after calling `set()` - it won't work as expected.\n *\n * @param options A {@link BundleId} object containing the new bundle id to set as current.\n * @returns {Promise<void>} A promise that will never resolve because the JavaScript context is destroyed.\n * @throws {Error} When there is no index.html file inside the bundle folder.\n */\n set(options: BundleId): Promise<void>;\n\n /**\n * Delete a bundle from local storage to free up disk space.\n *\n * You cannot delete:\n * - The currently active bundle\n * - The `builtin` bundle (the version shipped with your app)\n * - The bundle set as `next` (call {@link next} with a different bundle first)\n *\n * Use {@link list} to get all available bundle IDs.\n *\n * **Note:** The bundle ID is NOT the same as the version name.\n * Use the `id` field from {@link BundleInfo}, not the `version` field.\n *\n * @param options A {@link BundleId} object containing the bundle ID to delete.\n * @returns {Promise<void>} Resolves when the bundle is successfully deleted.\n * @throws {Error} If the bundle is currently in use or doesn't exist.\n */\n delete(options: BundleId): Promise<void>;\n\n /**\n * Manually mark a bundle as failed/errored in manual update mode.\n *\n * This is useful when you detect that a bundle has critical issues and want to prevent\n * it from being used again. The bundle status will be changed to `error` and the plugin\n * will avoid using this bundle in the future.\n *\n * **Requirements:**\n * - {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} must be set to `true`\n * - Only works in manual update mode (when autoUpdate is disabled)\n *\n * Common use case: After downloading and testing a bundle, you discover it has critical\n * bugs and want to mark it as failed so it won't be retried.\n *\n * @param options A {@link BundleId} object containing the bundle ID to mark as errored.\n * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} with status set to `error`.\n * @throws {Error} When the bundle does not exist or `allowManualBundleError` is false.\n * @since 7.20.0\n */\n setBundleError(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Get all locally downloaded bundles stored in your app.\n *\n * This returns all bundles that have been downloaded and are available locally, including:\n * - The currently active bundle\n * - The `builtin` bundle (shipped with your app)\n * - Any downloaded bundles waiting to be activated\n * - Failed bundles (with `error` status)\n *\n * Use this to:\n * - Check available disk space by counting bundles\n * - Delete old bundles with {@link delete}\n * - Monitor bundle download status\n *\n * @param options The {@link ListOptions} for customizing the bundle list output.\n * @returns {Promise<BundleListResult>} A promise containing the array of {@link BundleInfo} objects.\n * @throws {Error} If the operation fails.\n */\n list(options?: ListOptions): Promise<BundleListResult>;\n\n /**\n * Reset the app to a known good bundle.\n *\n * This method helps recover from problematic updates by reverting to either:\n * - The `builtin` bundle (the original version shipped with your app to App Store/Play Store)\n * - The last successfully loaded bundle (most recent bundle that worked correctly)\n *\n * **IMPORTANT: This triggers an immediate app reload, destroying the current JavaScript context.**\n * See {@link set} for details on the implications of this operation.\n *\n * Use cases:\n * - Emergency recovery when an update causes critical issues\n * - Testing rollback functionality\n * - Providing users a \"reset to factory\" option\n *\n * @param options {@link ResetOptions} to control reset behavior. If `toLastSuccessful` is `false` (or omitted), resets to builtin. If `true`, resets to last successful bundle.\n * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.\n * @throws {Error} If the reset operation fails.\n */\n reset(options?: ResetOptions): Promise<void>;\n\n /**\n * Get information about the currently active bundle.\n *\n * Returns:\n * - `bundle`: The currently active bundle information\n * - `native`: The version of the builtin bundle (the original app version from App/Play Store)\n *\n * If no updates have been applied, `bundle.id` will be `\"builtin\"`, indicating the app\n * is running the original version shipped with the native app.\n *\n * Use this to:\n * - Display the current version to users\n * - Check if an update is currently active\n * - Compare against available updates\n * - Log the active bundle for debugging\n *\n * @returns {Promise<CurrentBundleResult>} A promise with the current bundle and native version info.\n * @throws {Error} If the operation fails.\n */\n current(): Promise<CurrentBundleResult>;\n\n /**\n * Manually reload the app to apply a pending update.\n *\n * This triggers the same reload behavior that happens automatically when the app backgrounds.\n * If you've called {@link next} to queue an update, calling `reload()` will apply it immediately.\n *\n * **IMPORTANT: This destroys the current JavaScript context immediately.**\n * See {@link set} for details on the implications of this operation.\n *\n * Common use cases:\n * - Applying an update immediately after download instead of waiting for backgrounding\n * - Providing a \"Restart now\" button to users after an update is ready\n * - Testing update flows during development\n *\n * If no update is pending (no call to {@link next}), this simply reloads the current bundle.\n *\n * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.\n * @throws {Error} If the reload operation fails.\n */\n reload(): Promise<void>;\n\n /**\n * Configure conditions that must be met before a pending update is applied.\n *\n * After calling {@link next} to queue an update, use this method to control when it gets applied.\n * The update will only be installed after ALL specified conditions are satisfied.\n *\n * Available condition types:\n * - `background`: Wait for the app to be backgrounded. Optionally specify duration in milliseconds.\n * - `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.)\n * - `date`: Wait until a specific date/time (ISO 8601 format)\n * - `nativeVersion`: Wait until the native app is updated to a specific version\n *\n * Condition value formats:\n * - `background`: Number in milliseconds (e.g., `\"300000\"` for 5 minutes), or omit for immediate\n * - `kill`: No value needed\n * - `date`: ISO 8601 date string (e.g., `\"2025-12-31T23:59:59Z\"`)\n * - `nativeVersion`: Version string (e.g., `\"2.0.0\"`)\n *\n * @example\n * // Update after user kills app OR after 5 minutes in background\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [\n * { kind: 'kill' },\n * { kind: 'background', value: '300000' }\n * ]\n * });\n *\n * @example\n * // Update after a specific date\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [{ kind: 'date', value: '2025-12-31T23:59:59Z' }]\n * });\n *\n * @example\n * // Default behavior: update on next background\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [{ kind: 'background' }]\n * });\n *\n * @param options Contains the {@link MultiDelayConditions} array of conditions.\n * @returns {Promise<void>} Resolves when the delay conditions are set.\n * @throws {Error} If the operation fails or conditions are invalid.\n * @since 4.3.0\n */\n setMultiDelay(options: MultiDelayConditions): Promise<void>;\n\n /**\n * Cancel all delay conditions and apply the pending update immediately.\n *\n * If you've set delay conditions with {@link setMultiDelay}, this method clears them\n * and triggers the pending update to be applied on the next app background or restart.\n *\n * This is useful when:\n * - User manually requests to update now (e.g., clicks \"Update now\" button)\n * - Your app detects it's a good time to update (e.g., user finished critical task)\n * - You want to override a time-based delay early\n *\n * @returns {Promise<void>} Resolves when the delay conditions are cleared.\n * @throws {Error} If the operation fails.\n * @since 4.0.0\n */\n cancelDelay(): Promise<void>;\n\n /**\n * Check the update server for the latest available bundle version.\n *\n * This queries your configured update URL (or Capgo backend) to see if a newer bundle\n * is available for download. It does NOT download the bundle automatically.\n *\n * The response includes:\n * - `version`: The latest available version identifier\n * - `url`: Download URL for the bundle (if available)\n * - `breaking`: Whether this update is marked as incompatible (requires native app update)\n * - `message`: Optional message from the server\n * - `manifest`: File list for partial updates (if using multi-file downloads)\n *\n * After receiving the latest version info, you can:\n * 1. Compare it with your current version\n * 2. Download it using {@link download}\n * 3. Apply it using {@link next} or {@link set}\n *\n * **Important: Error handling for \"no new version available\"**\n *\n * When the device's current version matches the latest version on the server (i.e., the device is already\n * up-to-date), the server returns a 200 response with `error: \"no_new_version_available\"` and\n * `message: \"No new version available\"`. **This causes `getLatest()` to throw an error**, even though\n * this is a normal, expected condition.\n *\n * You should catch this specific error to handle it gracefully:\n *\n * ```typescript\n * try {\n * const latest = await CapacitorUpdater.getLatest();\n * // New version is available, proceed with download\n * } catch (error) {\n * if (error.message === 'No new version available') {\n * // Device is already on the latest version - this is normal\n * console.log('Already up to date');\n * } else {\n * // Actual error occurred\n * console.error('Failed to check for updates:', error);\n * }\n * }\n * ```\n *\n * In this scenario, the server:\n * - Logs the request with a \"No new version available\" message\n * - Sends a \"noNew\" stat action to track that the device checked for updates but was already current (done on the backend)\n *\n * @param options Optional {@link GetLatestOptions} to specify which channel to check.\n * @returns {Promise<LatestVersion>} Information about the latest available bundle version.\n * @throws {Error} Always throws when no new version is available (`error: \"no_new_version_available\"`), or when the request fails.\n * @since 4.0.0\n */\n getLatest(options?: GetLatestOptions): Promise<LatestVersion>;\n\n /**\n * Assign this device to a specific update channel at runtime.\n *\n * Channels allow you to distribute different bundle versions to different groups of users\n * (e.g., \"production\", \"beta\", \"staging\"). This method switches the device to a new channel.\n *\n * **Requirements:**\n * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)\n * - The backend may accept or reject the request based on channel settings\n *\n * **When to use:**\n * - After the app is ready and the user has interacted (e.g., opted into beta program)\n * - To implement in-app channel switching (beta toggle, tester access, etc.)\n * - For user-driven channel changes\n *\n * **When NOT to use:**\n * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead\n * - Before user interaction\n *\n * **Important: Listen for the `channelPrivate` event**\n *\n * When a user attempts to set a channel that doesn't allow device self-assignment, the method will\n * throw an error AND fire a {@link addListener}('channelPrivate') event. You should listen to this event\n * to provide appropriate feedback to users:\n *\n * ```typescript\n * CapacitorUpdater.addListener('channelPrivate', (data) => {\n * console.warn(`Cannot access channel \"${data.channel}\": ${data.message}`);\n * // Show user-friendly message\n * });\n * ```\n *\n * This sends a request to the Capgo backend linking your device ID to the specified channel.\n *\n * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.\n * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.\n * @throws {Error} If the channel doesn't exist or doesn't allow self-assignment.\n * @since 4.7.0\n */\n setChannel(options: SetChannelOptions): Promise<ChannelRes>;\n\n /**\n * Remove the device's channel assignment and return to the default channel.\n *\n * This unlinks the device from any specifically assigned channel, causing it to fall back to:\n * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or\n * - Your backend's default channel for this app\n *\n * Use this when:\n * - Users opt out of beta/testing programs\n * - You want to reset a device to standard update distribution\n * - Testing channel switching behavior\n *\n * @param options {@link UnsetChannelOptions} containing optional auto-update trigger.\n * @returns {Promise<void>} Resolves when the channel is successfully unset.\n * @throws {Error} If the operation fails.\n * @since 4.7.0\n */\n unsetChannel(options: UnsetChannelOptions): Promise<void>;\n\n /**\n * Get the current channel assigned to this device.\n *\n * Returns information about:\n * - `channel`: The currently assigned channel name (if any)\n * - `allowSet`: Whether the channel allows self-assignment\n * - `status`: Operation status\n * - `error`/`message`: Additional information (if applicable)\n *\n * Use this to:\n * - Display current channel to users (e.g., \"You're on the Beta channel\")\n * - Check if a device is on a specific channel before showing features\n * - Verify channel assignment after calling {@link setChannel}\n *\n * @returns {Promise<GetChannelRes>} The current channel information.\n * @throws {Error} If the operation fails.\n * @since 4.8.0\n */\n getChannel(): Promise<GetChannelRes>;\n\n /**\n * Get a list of all channels available for this device to self-assign to.\n *\n * Only returns channels where `allow_self_set` is `true`. These are channels that\n * users can switch to using {@link setChannel} without backend administrator intervention.\n *\n * Each channel includes:\n * - `id`: Unique channel identifier\n * - `name`: Human-readable channel name\n * - `public`: Whether the channel is publicly visible\n * - `allow_self_set`: Always `true` in results (filtered to only self-assignable channels)\n *\n * Use this to:\n * - Build a channel selector UI for users (e.g., \"Join Beta\" button)\n * - Show available testing/preview channels\n * - Implement channel discovery features\n *\n * @returns {Promise<ListChannelsResult>} List of channels the device can self-assign to.\n * @throws {Error} If the operation fails or the request to the backend fails.\n * @since 7.5.0\n */\n listChannels(): Promise<ListChannelsResult>;\n\n /**\n * Set a custom identifier for this device.\n *\n * This allows you to identify devices by your own custom ID (user ID, account ID, etc.)\n * instead of or in addition to the device's unique hardware ID. The custom ID is sent\n * to your update server and can be used for:\n * - Targeting specific users for updates\n * - Analytics and user tracking\n * - Debugging and support (correlating devices with users)\n * - A/B testing or feature flagging\n *\n * **Persistence:**\n * - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true`, the ID persists across app restarts\n * - When `false`, the ID is only kept for the current session\n *\n * **Clearing the custom ID:**\n * - Pass an empty string `\"\"` to remove any stored custom ID\n *\n * @param options The {@link SetCustomIdOptions} containing the custom identifier string.\n * @returns {Promise<void>} Resolves immediately (synchronous operation).\n * @throws {Error} If the operation fails.\n * @since 4.9.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n\n /**\n * Get the builtin bundle version (the original version shipped with your native app).\n *\n * This returns the version of the bundle that was included when the app was installed\n * from the App Store or Play Store. This is NOT the currently active bundle version -\n * use {@link current} for that.\n *\n * Returns:\n * - The {@link PluginsConfig.CapacitorUpdater.version} config value if set, or\n * - The native app version from platform configs (package.json, Info.plist, build.gradle)\n *\n * Use this to:\n * - Display the \"factory\" version to users\n * - Compare against downloaded bundle versions\n * - Determine if any updates have been applied\n * - Debugging version mismatches\n *\n * @returns {Promise<BuiltinVersion>} The builtin bundle version string.\n * @since 5.2.0\n */\n getBuiltinVersion(): Promise<BuiltinVersion>;\n\n /**\n * Get the unique, privacy-friendly identifier for this device.\n *\n * This ID is used to identify the device when communicating with update servers.\n * It's automatically generated and stored securely by the plugin.\n *\n * **Privacy & Security characteristics:**\n * - Generated as a UUID (not based on hardware identifiers)\n * - Stored securely in platform-specific secure storage\n * - Android: Android Keystore (persists across app reinstalls on API 23+)\n * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`\n * - Not synced to cloud (iOS)\n * - Follows Apple and Google privacy best practices\n * - Users can clear it via system settings (Android) or keychain access (iOS)\n *\n * **Persistence:**\n * The device ID persists across app reinstalls to maintain consistent device identity\n * for update tracking and analytics.\n *\n * Use this to:\n * - Debug update delivery issues (check what ID the server sees)\n * - Implement device-specific features\n * - Correlate server logs with specific devices\n *\n * @returns {Promise<DeviceId>} The unique device identifier string.\n * @throws {Error} If the operation fails.\n */\n getDeviceId(): Promise<DeviceId>;\n\n /**\n * Get the version of the Capacitor Updater plugin installed in your app.\n *\n * This returns the version of the native plugin code (Android/iOS), which is sent\n * to the update server with each request. This is NOT your app version or bundle version.\n *\n * Use this to:\n * - Debug plugin-specific issues (when reporting bugs)\n * - Verify plugin installation and version\n * - Check compatibility with backend features\n * - Display in debug/about screens\n *\n * @returns {Promise<PluginVersion>} The Capacitor Updater plugin version string.\n * @throws {Error} If the operation fails.\n */\n getPluginVersion(): Promise<PluginVersion>;\n\n /**\n * Check if automatic updates are currently enabled.\n *\n * Returns `true` if {@link PluginsConfig.CapacitorUpdater.autoUpdate} is enabled,\n * meaning the plugin will automatically check for, download, and apply updates.\n *\n * Returns `false` if in manual mode, where you control the update flow using\n * {@link getLatest}, {@link download}, {@link next}, and {@link set}.\n *\n * Use this to:\n * - Determine which update flow your app is using\n * - Show/hide manual update UI based on mode\n * - Debug update behavior\n *\n * @returns {Promise<AutoUpdateEnabled>} `true` if auto-update is enabled, `false` if in manual mode.\n * @throws {Error} If the operation fails.\n */\n isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;\n\n /**\n * Remove all event listeners registered for this plugin.\n *\n * This unregisters all listeners added via {@link addListener} for all event types:\n * - `download`\n * - `noNeedUpdate`\n * - `updateAvailable`\n * - `downloadComplete`\n * - `downloadFailed`\n * - `breakingAvailable` / `majorAvailable`\n * - `updateFailed`\n * - `appReloaded`\n * - `appReady`\n *\n * Use this during cleanup (e.g., when unmounting components or closing screens)\n * to prevent memory leaks from lingering event listeners.\n *\n * @returns {Promise<void>} Resolves when all listeners are removed.\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.\n * This will return you all download percent during the download\n *\n * @since 2.0.11\n */\n addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for no need to update event, useful when you want force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for available update event, useful when you want to force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'updateAvailable',\n listenerFunc: (state: UpdateAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for downloadComplete events.\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadComplete',\n listenerFunc: (state: DownloadCompleteEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for breaking update events when the backend flags an update as incompatible with the current app.\n * Emits the same payload as the legacy `majorAvailable` listener.\n *\n * @since 7.22.0\n */\n addListener(\n eventName: 'breakingAvailable',\n listenerFunc: (state: BreakingAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking\n *\n * @deprecated Deprecated alias for {@link addListener} with `breakingAvailable`. Emits the same payload. will be removed in v8\n * @since 2.3.0\n */\n addListener(\n eventName: 'majorAvailable',\n listenerFunc: (state: MajorAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for update fail event in the App, let you know when update has fail to install at next app start\n *\n * @since 2.3.0\n */\n addListener(\n eventName: 'updateFailed',\n listenerFunc: (state: UpdateFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for download fail event in the App, let you know when a bundle download has failed\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadFailed',\n listenerFunc: (state: DownloadFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for reload event in the App, let you know when reload has happened\n *\n * @since 4.3.0\n */\n addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for app ready event in the App, let you know when app is ready to use, this event is retain till consumed.\n *\n * @since 5.1.0\n */\n addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.\n *\n * This event is useful for:\n * - Informing users they don't have permission to switch to a specific channel\n * - Implementing custom error handling for channel restrictions\n * - Logging unauthorized channel access attempts\n *\n * @since 7.34.0\n */\n addListener(\n eventName: 'channelPrivate',\n listenerFunc: (state: ChannelPrivateEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Check if the auto-update feature is available (not disabled by custom server configuration).\n *\n * Returns `false` when a custom `updateUrl` is configured, as this typically indicates\n * you're using a self-hosted update server that may not support all auto-update features.\n *\n * Returns `true` when using the default Capgo backend or when the feature is available.\n *\n * This is different from {@link isAutoUpdateEnabled}:\n * - `isAutoUpdateEnabled()`: Checks if auto-update MODE is turned on/off\n * - `isAutoUpdateAvailable()`: Checks if auto-update is SUPPORTED with your current configuration\n *\n * @returns {Promise<AutoUpdateAvailable>} `false` when custom updateUrl is set, `true` otherwise.\n * @throws {Error} If the operation fails.\n */\n isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;\n\n /**\n * Get information about the bundle queued to be activated on next reload.\n *\n * Returns:\n * - {@link BundleInfo} object if a bundle has been queued via {@link next}\n * - `null` if no update is pending\n *\n * This is useful to:\n * - Check if an update is waiting to be applied\n * - Display \"Update pending\" status to users\n * - Show version info of the queued update\n * - Decide whether to show a \"Restart to update\" prompt\n *\n * The queued bundle will be activated when:\n * - The app is backgrounded (default behavior)\n * - The app is killed and restarted\n * - {@link reload} is called manually\n * - Delay conditions set by {@link setMultiDelay} are met\n *\n * @returns {Promise<BundleInfo | null>} The pending bundle info, or `null` if none is queued.\n * @throws {Error} If the operation fails.\n * @since 6.8.0\n */\n getNextBundle(): Promise<BundleInfo | null>;\n\n /**\n * Retrieve information about the most recent bundle that failed to load.\n *\n * When a bundle fails to load (e.g., JavaScript errors prevent initialization, missing files),\n * the plugin automatically rolls back and stores information about the failure. This method\n * retrieves that failure information.\n *\n * **IMPORTANT: The stored value is cleared after being retrieved once.**\n * Calling this method multiple times will only return the failure info on the first call,\n * then `null` on subsequent calls until another failure occurs.\n *\n * Returns:\n * - {@link UpdateFailedEvent} with bundle info if a failure was recorded\n * - `null` if no failure has occurred or if it was already retrieved\n *\n * Use this to:\n * - Show users why an update failed\n * - Log failure information for debugging\n * - Implement custom error handling/reporting\n * - Display rollback notifications\n *\n * @returns {Promise<UpdateFailedEvent | null>} The failed update info (cleared after first retrieval), or `null`.\n * @throws {Error} If the operation fails.\n * @since 7.22.0\n */\n getFailedUpdate(): Promise<UpdateFailedEvent | null>;\n\n /**\n * Enable or disable the shake gesture menu for debugging and testing.\n *\n * When enabled, users can shake their device to open a debug menu that shows:\n * - Current bundle information\n * - Available bundles\n * - Options to switch bundles manually\n * - Update status\n *\n * This is useful during development and testing to:\n * - Quickly test different bundle versions\n * - Debug update flows\n * - Switch between production and test bundles\n * - Verify bundle installations\n *\n * **Important:** Disable this in production builds or only enable for internal testers.\n *\n * Can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.\n *\n * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.\n * @returns {Promise<void>} Resolves when the setting is applied.\n * @throws {Error} If the operation fails.\n * @since 7.5.0\n */\n setShakeMenu(options: SetShakeMenuOptions): Promise<void>;\n\n /**\n * Check if the shake gesture debug menu is currently enabled.\n *\n * Returns the current state of the shake menu feature that can be toggled via\n * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.\n *\n * Use this to:\n * - Check if debug features are enabled\n * - Show/hide debug settings UI\n * - Verify configuration during testing\n *\n * @returns {Promise<ShakeMenuEnabled>} Object with `enabled: true` or `enabled: false`.\n * @throws {Error} If the operation fails.\n * @since 7.5.0\n */\n isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;\n\n /**\n * Get the currently configured App ID used for update server communication.\n *\n * Returns the App ID that identifies this app to the update server. This can be:\n * - The value set via {@link setAppId}, or\n * - The {@link PluginsConfig.CapacitorUpdater.appId} config value, or\n * - The default app identifier from your native app configuration\n *\n * Use this to:\n * - Verify which App ID is being used for updates\n * - Debug update delivery issues\n * - Display app configuration in debug screens\n * - Confirm App ID after calling {@link setAppId}\n *\n * @returns {Promise<GetAppIdRes>} Object containing the current `appId` string.\n * @throws {Error} If the operation fails.\n * @since 7.14.0\n */\n getAppId(): Promise<GetAppIdRes>;\n\n /**\n * Dynamically change the App ID used for update server communication.\n *\n * This overrides the App ID used to identify your app to the update server, allowing you\n * to switch between different app configurations at runtime (e.g., production vs staging\n * app IDs, or multi-tenant configurations).\n *\n * **Requirements:**\n * - {@link PluginsConfig.CapacitorUpdater.allowModifyAppId} must be set to `true`\n *\n * **Important considerations:**\n * - Changing the App ID will affect which updates this device receives\n * - The new App ID must exist on your update server\n * - This is primarily for advanced use cases (multi-tenancy, environment switching)\n * - Most apps should use the config-based {@link PluginsConfig.CapacitorUpdater.appId} instead\n *\n * @param options {@link SetAppIdOptions} containing the new App ID string.\n * @returns {Promise<void>} Resolves when the App ID is successfully changed.\n * @throws {Error} If `allowModifyAppId` is false or the operation fails.\n * @since 7.14.0\n */\n setAppId(options: SetAppIdOptions): Promise<void>;\n}\n\n/**\n * pending: The bundle is pending to be **SET** as the next bundle.\n * downloading: The bundle is being downloaded.\n * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.\n * error: The bundle has failed to download.\n */\nexport type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';\n\nexport type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';\n\nexport interface NoNeedEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateAvailableEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface ChannelRes {\n /**\n * Current status of set channel\n *\n * @since 4.7.0\n */\n status: string;\n error?: string;\n message?: string;\n}\n\nexport interface GetChannelRes {\n /**\n * Current status of get channel\n *\n * @since 4.8.0\n */\n channel?: string;\n error?: string;\n message?: string;\n status?: string;\n allowSet?: boolean;\n}\n\nexport interface ChannelInfo {\n /**\n * The channel ID\n *\n * @since 7.5.0\n */\n id: string;\n /**\n * The channel name\n *\n * @since 7.5.0\n */\n name: string;\n /**\n * Whether this is a public channel\n *\n * @since 7.5.0\n */\n public: boolean;\n /**\n * Whether devices can self-assign to this channel\n *\n * @since 7.5.0\n */\n allow_self_set: boolean;\n}\n\nexport interface ListChannelsResult {\n /**\n * List of available channels\n *\n * @since 7.5.0\n */\n channels: ChannelInfo[];\n}\n\nexport interface DownloadEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n percent: number;\n bundle: BundleInfo;\n}\n\nexport interface MajorAvailableEvent {\n /**\n * Emit when a breaking update is available.\n *\n * @deprecated Deprecated alias for {@link BreakingAvailableEvent}. Receives the same payload.\n * @since 4.0.0\n */\n version: string;\n}\n\n/**\n * Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvailable`.\n *\n * @since 7.22.0\n */\nexport type BreakingAvailableEvent = MajorAvailableEvent;\n\nexport interface DownloadFailedEvent {\n /**\n * Emit when a download fail.\n *\n * @since 4.0.0\n */\n version: string;\n}\n\nexport interface DownloadCompleteEvent {\n /**\n * Emit when a new update is available.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateFailedEvent {\n /**\n * Emit when a update failed to install.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface AppReadyEvent {\n /**\n * Emitted when the app is ready to use.\n *\n * @since 5.2.0\n */\n bundle: BundleInfo;\n status: string;\n}\n\nexport interface ChannelPrivateEvent {\n /**\n * Emitted when attempting to set a channel that doesn't allow device self-assignment.\n *\n * @since 7.34.0\n */\n channel: string;\n message: string;\n}\n\nexport interface ManifestEntry {\n file_name: string | null;\n file_hash: string | null;\n download_url: string | null;\n}\n\nexport interface LatestVersion {\n /**\n * Result of getLatest method\n *\n * @since 4.0.0\n */\n version: string;\n /**\n * @since 6\n */\n checksum?: string;\n /**\n * Indicates whether the update was flagged as breaking by the backend.\n *\n * @since 7.22.0\n */\n breaking?: boolean;\n /**\n * @deprecated Use {@link LatestVersion.breaking} instead.\n */\n major?: boolean;\n /**\n * Optional message from the server.\n * When no new version is available, this will be \"No new version available\".\n */\n message?: string;\n sessionKey?: string;\n /**\n * Error code from the server, if any.\n * Common values:\n * - `\"no_new_version_available\"`: Device is already on the latest version (not a failure)\n * - Other error codes indicate actual failures in the update process\n */\n error?: string;\n /**\n * The previous/current version name (provided for reference).\n */\n old?: string;\n /**\n * Download URL for the bundle (when a new version is available).\n */\n url?: string;\n /**\n * File list for partial updates (when using multi-file downloads).\n * @since 6.1\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleInfo {\n id: string;\n version: string;\n downloaded: string;\n checksum: string;\n status: BundleStatus;\n}\n\nexport interface SetChannelOptions {\n channel: string;\n triggerAutoUpdate?: boolean;\n}\n\nexport interface UnsetChannelOptions {\n triggerAutoUpdate?: boolean;\n}\n\nexport interface SetCustomIdOptions {\n /**\n * Custom identifier to associate with the device. Use an empty string to clear any saved value.\n */\n customId: string;\n}\n\nexport interface DelayCondition {\n /**\n * Set up delay conditions in setMultiDelay\n * @param value is useless for @param kind \"kill\", optional for \"background\" (default value: \"0\") and required for \"nativeVersion\" and \"date\"\n */\n kind: DelayUntilNext;\n value?: string;\n}\n\nexport interface GetLatestOptions {\n /**\n * The channel to get the latest version for\n * The channel must allow 'self_assign' for this to work\n * @since 6.8.0\n * @default undefined\n */\n channel?: string;\n}\n\nexport interface AppReadyResult {\n bundle: BundleInfo;\n}\n\nexport interface UpdateUrl {\n url: string;\n}\n\nexport interface StatsUrl {\n url: string;\n}\n\nexport interface ChannelUrl {\n url: string;\n}\n\n/**\n * 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.\n * 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.\n */\nexport interface DownloadOptions {\n /**\n * 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.)\n */\n url: string;\n /**\n * The version code/name of this bundle/version\n */\n version: string;\n /**\n * The session key for the update, when the bundle is encrypted with a session key\n * @since 4.0.0\n * @default undefined\n */\n sessionKey?: string;\n /**\n * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted\n * @since 4.0.0\n * @default undefined\n */\n checksum?: string;\n /**\n * The manifest for multi-file downloads\n * @since 6.1.0\n * @default undefined\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleId {\n id: string;\n}\n\nexport interface BundleListResult {\n bundles: BundleInfo[];\n}\n\nexport interface ResetOptions {\n toLastSuccessful: boolean;\n}\n\nexport interface ListOptions {\n /**\n * 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.\n * @since 6.14.0\n * @default false\n */\n raw?: boolean;\n}\n\nexport interface CurrentBundleResult {\n bundle: BundleInfo;\n native: string;\n}\n\nexport interface MultiDelayConditions {\n delayConditions: DelayCondition[];\n}\n\nexport interface BuiltinVersion {\n version: string;\n}\n\nexport interface DeviceId {\n deviceId: string;\n}\n\nexport interface PluginVersion {\n version: string;\n}\n\nexport interface AutoUpdateEnabled {\n enabled: boolean;\n}\n\nexport interface AutoUpdateAvailable {\n available: boolean;\n}\n\nexport interface SetShakeMenuOptions {\n enabled: boolean;\n}\n\nexport interface ShakeMenuEnabled {\n enabled: boolean;\n}\n\nexport interface GetAppIdRes {\n appId: string;\n}\n\nexport interface SetAppIdOptions {\n appId: string;\n}\n"]}
@@ -54,7 +54,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
54
54
  CAPPluginMethod(name: "isShakeMenuEnabled", returnType: CAPPluginReturnPromise)
55
55
  ]
56
56
  public var implementation = CapgoUpdater()
57
- private let pluginVersion: String = "7.33.4"
57
+ private let pluginVersion: String = "7.34.0"
58
58
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
59
59
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
60
60
  static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
@@ -63,6 +63,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
63
63
  private let updateUrlDefaultsKey = "CapacitorUpdater.updateUrl"
64
64
  private let statsUrlDefaultsKey = "CapacitorUpdater.statsUrl"
65
65
  private let channelUrlDefaultsKey = "CapacitorUpdater.channelUrl"
66
+ private let defaultChannelDefaultsKey = "CapacitorUpdater.defaultChannel"
66
67
  private let lastFailedBundleDefaultsKey = "CapacitorUpdater.lastFailedBundle"
67
68
  // Note: DELAY_CONDITION_PREFERENCES is now defined in DelayUpdateUtils.DELAY_CONDITION_PREFERENCES
68
69
  private var updateUrl = ""
@@ -86,6 +87,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
86
87
  private var autoSplashscreenTimedOut = false
87
88
  private var autoDeleteFailed = false
88
89
  private var autoDeletePrevious = false
90
+ private var allowSetDefaultChannel = true
89
91
  private var keepUrlPathAfterReload = false
90
92
  private var backgroundWork: DispatchWorkItem?
91
93
  private var taskRunning = false
@@ -117,6 +119,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
117
119
  // Use DeviceIdHelper to get or create device ID that persists across reinstalls
118
120
  self.implementation.deviceID = DeviceIdHelper.getOrCreateDeviceId()
119
121
  persistCustomId = getConfig().getBoolean("persistCustomId", false)
122
+ allowSetDefaultChannel = getConfig().getBoolean("allowSetDefaultChannel", true)
120
123
  if persistCustomId {
121
124
  let storedCustomId = UserDefaults.standard.string(forKey: customIdDefaultsKey) ?? ""
122
125
  if !storedCustomId.isEmpty {
@@ -224,7 +227,14 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
224
227
  logger.info("Loaded persisted channelUrl")
225
228
  }
226
229
  }
227
- implementation.defaultChannel = getConfig().getString("defaultChannel", "")!
230
+
231
+ // Load defaultChannel: first try from persistent storage (set via setChannel), then fall back to config
232
+ if let storedDefaultChannel = UserDefaults.standard.object(forKey: defaultChannelDefaultsKey) as? String {
233
+ implementation.defaultChannel = storedDefaultChannel
234
+ logger.info("Loaded persisted defaultChannel from setChannel()")
235
+ } else {
236
+ implementation.defaultChannel = getConfig().getString("defaultChannel", "")!
237
+ }
228
238
  self.implementation.autoReset()
229
239
 
230
240
  // Check if app was recently installed/updated BEFORE cleanupObsoleteVersions updates LatestVersionNative
@@ -698,7 +708,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
698
708
  @objc func unsetChannel(_ call: CAPPluginCall) {
699
709
  let triggerAutoUpdate = call.getBool("triggerAutoUpdate", false)
700
710
  DispatchQueue.global(qos: .background).async {
701
- let res = self.implementation.unsetChannel()
711
+ let configDefaultChannel = self.getConfig().getString("defaultChannel", "")!
712
+ let res = self.implementation.unsetChannel(defaultChannelKey: self.defaultChannelDefaultsKey, configDefaultChannel: configDefaultChannel)
702
713
  if res.error != "" {
703
714
  call.reject(res.error, "UNSETCHANNEL_FAILED", nil, [
704
715
  "message": res.error,
@@ -725,11 +736,18 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
725
736
  }
726
737
  let triggerAutoUpdate = call.getBool("triggerAutoUpdate") ?? false
727
738
  DispatchQueue.global(qos: .background).async {
728
- let res = self.implementation.setChannel(channel: channel)
739
+ let res = self.implementation.setChannel(channel: channel, defaultChannelKey: self.defaultChannelDefaultsKey, allowSetDefaultChannel: self.allowSetDefaultChannel)
729
740
  if res.error != "" {
741
+ // Fire channelPrivate event if channel doesn't allow self-assignment
742
+ if res.error.contains("cannot_update_via_private_channel") || res.error.contains("channel_self_set_not_allowed") {
743
+ self.notifyListeners("channelPrivate", data: [
744
+ "channel": channel,
745
+ "message": res.error
746
+ ])
747
+ }
730
748
  call.reject(res.error, "SETCHANNEL_FAILED", nil, [
731
749
  "message": res.error,
732
- "error": res.error.contains("Channel URL") ? "missing_config" : "request_failed"
750
+ "error": res.error.contains("Channel URL") ? "missing_config" : (res.error.contains("cannot_update_via_private_channel") || res.error.contains("channel_self_set_not_allowed")) ? "channel_private" : "request_failed"
733
751
  ])
734
752
  } else {
735
753
  if self._isAutoUpdateEnabled() && triggerAutoUpdate {
@@ -1111,60 +1111,31 @@ import UIKit
1111
1111
  self.setBundleStatus(id: bundle.getId(), status: BundleStatus.ERROR)
1112
1112
  }
1113
1113
 
1114
- func unsetChannel() -> SetChannel {
1114
+ func unsetChannel(defaultChannelKey: String, configDefaultChannel: String) -> SetChannel {
1115
1115
  let setChannel: SetChannel = SetChannel()
1116
1116
 
1117
- // Check if rate limit was exceeded
1118
- if CapgoUpdater.rateLimitExceeded {
1119
- logger.debug("Skipping unsetChannel due to rate limit (429). Requests will resume after app restart.")
1120
- setChannel.message = "Rate limit exceeded"
1121
- setChannel.error = "rate_limit_exceeded"
1122
- return setChannel
1123
- }
1124
-
1125
- if (self.channelUrl ).isEmpty {
1126
- logger.error("Channel URL is not set")
1127
- setChannel.message = "Channel URL is not set"
1128
- setChannel.error = "missing_config"
1129
- return setChannel
1130
- }
1131
- let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0)
1132
- let parameters: InfoObject = self.createInfoObject()
1133
-
1134
- let request = alamofireSession.request(self.channelUrl, method: .delete, parameters: parameters, encoder: JSONParameterEncoder.default, requestModifier: { $0.timeoutInterval = self.timeout })
1135
-
1136
- request.validate().responseDecodable(of: SetChannelDec.self) { response in
1137
- // Check for 429 rate limit
1138
- if self.checkAndHandleRateLimitResponse(statusCode: response.response?.statusCode) {
1139
- setChannel.message = "Rate limit exceeded"
1140
- setChannel.error = "rate_limit_exceeded"
1141
- semaphore.signal()
1142
- return
1143
- }
1117
+ // Clear persisted defaultChannel and revert to config value
1118
+ UserDefaults.standard.removeObject(forKey: defaultChannelKey)
1119
+ UserDefaults.standard.synchronize()
1120
+ self.defaultChannel = configDefaultChannel
1121
+ self.logger.info("Persisted defaultChannel cleared, reverted to config value: \(configDefaultChannel)")
1144
1122
 
1145
- switch response.result {
1146
- case .success:
1147
- if let responseValue = response.value {
1148
- if let error = responseValue.error {
1149
- setChannel.error = error
1150
- } else {
1151
- setChannel.status = responseValue.status ?? ""
1152
- setChannel.message = responseValue.message ?? ""
1153
- }
1154
- }
1155
- case let .failure(error):
1156
- self.logger.error("Error unset Channel \(error)")
1157
- setChannel.error = "Request failed: \(error.localizedDescription)"
1158
- }
1159
- semaphore.signal()
1160
- }
1161
- semaphore.wait()
1123
+ setChannel.status = "ok"
1124
+ setChannel.message = "Channel override removed"
1162
1125
  return setChannel
1163
1126
  }
1164
1127
 
1165
- func setChannel(channel: String) -> SetChannel {
1128
+ func setChannel(channel: String, defaultChannelKey: String, allowSetDefaultChannel: Bool) -> SetChannel {
1166
1129
  let setChannel: SetChannel = SetChannel()
1167
1130
 
1131
+ // Check if setting defaultChannel is allowed
1132
+ if !allowSetDefaultChannel {
1133
+ logger.error("setChannel is disabled by allowSetDefaultChannel config")
1134
+ setChannel.message = "setChannel is disabled by configuration"
1135
+ setChannel.error = "disabled_by_config"
1136
+ return setChannel
1137
+ }
1138
+
1168
1139
  // Check if rate limit was exceeded
1169
1140
  if CapgoUpdater.rateLimitExceeded {
1170
1141
  logger.debug("Skipping setChannel due to rate limit (429). Requests will resume after app restart.")
@@ -1200,6 +1171,12 @@ import UIKit
1200
1171
  if let error = responseValue.error {
1201
1172
  setChannel.error = error
1202
1173
  } else {
1174
+ // Success - persist defaultChannel
1175
+ self.defaultChannel = channel
1176
+ UserDefaults.standard.set(channel, forKey: defaultChannelKey)
1177
+ UserDefaults.standard.synchronize()
1178
+ self.logger.info("defaultChannel persisted locally: \(channel)")
1179
+
1203
1180
  setChannel.status = responseValue.status ?? ""
1204
1181
  setChannel.message = responseValue.message ?? ""
1205
1182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "7.33.4",
3
+ "version": "7.34.0",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",