@capgo/capacitor-updater 5.2.30 → 5.2.32

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
@@ -677,9 +677,10 @@ Remove all listeners for this plugin.
677
677
 
678
678
  #### SetChannelOptions
679
679
 
680
- | Prop | Type |
681
- | ------------- | ------------------- |
682
- | **`channel`** | <code>string</code> |
680
+ | Prop | Type |
681
+ | ----------------------- | -------------------- |
682
+ | **`channel`** | <code>string</code> |
683
+ | **`triggerAutoUpdate`** | <code>boolean</code> |
683
684
 
684
685
 
685
686
  #### getChannelRes
@@ -58,7 +58,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
58
58
  private static final String channelUrlDefault =
59
59
  "https://api.capgo.app/channel_self";
60
60
 
61
- private final String PLUGIN_VERSION = "5.2.30";
61
+ private final String PLUGIN_VERSION = "5.2.32";
62
62
  private static final String DELAY_CONDITION_PREFERENCES = "";
63
63
 
64
64
  private SharedPreferences.Editor editor;
@@ -388,13 +388,21 @@ public class CapacitorUpdaterPlugin extends Plugin {
388
388
  @PluginMethod
389
389
  public void setChannel(final PluginCall call) {
390
390
  final String channel = call.getString("channel");
391
+ final Boolean triggerAutoUpdate = call.getBoolean(
392
+ "triggerAutoUpdate",
393
+ false
394
+ );
395
+
391
396
  if (channel == null) {
392
397
  Log.e(CapacitorUpdater.TAG, "setChannel called without channel");
393
398
  call.reject("setChannel called without channel");
394
399
  return;
395
400
  }
396
401
  try {
397
- Log.i(CapacitorUpdater.TAG, "setChannel " + channel);
402
+ Log.i(
403
+ CapacitorUpdater.TAG,
404
+ "setChannel " + channel + " triggerAutoUpdate: " + triggerAutoUpdate
405
+ );
398
406
  startNewThread(() -> {
399
407
  CapacitorUpdaterPlugin.this.implementation.setChannel(
400
408
  channel,
@@ -402,6 +410,16 @@ public class CapacitorUpdaterPlugin extends Plugin {
402
410
  if (res.has("error")) {
403
411
  call.reject(res.getString("error"));
404
412
  } else {
413
+ if (
414
+ CapacitorUpdaterPlugin.this._isAutoUpdateEnabled() &&
415
+ triggerAutoUpdate
416
+ ) {
417
+ Log.i(
418
+ CapacitorUpdater.TAG,
419
+ "Calling autoupdater after channel change!"
420
+ );
421
+ backgroundDownload();
422
+ }
405
423
  call.resolve(res);
406
424
  }
407
425
  }
package/dist/docs.json CHANGED
@@ -978,6 +978,13 @@
978
978
  "docs": "",
979
979
  "complexTypes": [],
980
980
  "type": "string"
981
+ },
982
+ {
983
+ "name": "triggerAutoUpdate",
984
+ "tags": [],
985
+ "docs": "",
986
+ "complexTypes": [],
987
+ "type": "boolean | undefined"
981
988
  }
982
989
  ]
983
990
  },
@@ -209,6 +209,7 @@ export interface BundleInfo {
209
209
  }
210
210
  export interface SetChannelOptions {
211
211
  channel: string;
212
+ triggerAutoUpdate?: boolean;
212
213
  }
213
214
  export interface SetCustomIdOptions {
214
215
  customId: string;
@@ -15,7 +15,7 @@ import Version
15
15
  @objc(CapacitorUpdaterPlugin)
16
16
  public class CapacitorUpdaterPlugin: CAPPlugin {
17
17
  public var implementation = CapacitorUpdater()
18
- private let PLUGIN_VERSION: String = "5.2.30"
18
+ private let PLUGIN_VERSION: String = "5.2.32"
19
19
  static let updateUrlDefault = "https://api.capgo.app/updates"
20
20
  static let statsUrlDefault = "https://api.capgo.app/stats"
21
21
  static let channelUrlDefault = "https://api.capgo.app/channel_self"
@@ -179,8 +179,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
179
179
  guard let bridge = self.bridge else { return false }
180
180
  self.semaphoreUp()
181
181
  let id = self.implementation.getCurrentBundleId()
182
- let dest : URL
183
- if (BundleInfo.ID_BUILTIN == id) {
182
+ let dest: URL
183
+ if BundleInfo.ID_BUILTIN == id {
184
184
  dest = Bundle.main.resourceURL!.appendingPathComponent("public")
185
185
  } else {
186
186
  dest = self.implementation.getPathHot(id: id)
@@ -280,11 +280,16 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
280
280
  call.reject("setChannel called without channel")
281
281
  return
282
282
  }
283
+ let triggerAutoUpdate = call.getBool("triggerAutoUpdate") ?? false
283
284
  DispatchQueue.global(qos: .background).async {
284
285
  let res = self.implementation.setChannel(channel: channel)
285
286
  if res.error != "" {
286
287
  call.reject(res.error)
287
288
  } else {
289
+ if self._isAutoUpdateEnabled() {
290
+ print("\(self.implementation.TAG) Calling autoupdater after channel change!")
291
+ self.backgroundDownload()
292
+ }
288
293
  call.resolve(res.toDict())
289
294
  }
290
295
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "5.2.30",
3
+ "version": "5.2.32",
4
4
  "packageManager": "pnpm@8.7.0",
5
5
  "license": "MPL-2.0",
6
6
  "description": "Live update for capacitor apps",