@capgo/capacitor-updater 4.6.2 → 4.7.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
@@ -137,6 +137,7 @@ Capacitor Updator works by unzipping a compiled app bundle to the native device
137
137
  * [`setDelay(...)`](#setdelay)
138
138
  * [`cancelDelay()`](#canceldelay)
139
139
  * [`getLatest()`](#getlatest)
140
+ * [`setChannel()`](#setchannel)
140
141
  * [`addListener('download', ...)`](#addlistenerdownload)
141
142
  * [`addListener('noNeedUpdate', ...)`](#addlistenernoneedupdate)
142
143
  * [`addListener('updateAvailable', ...)`](#addlistenerupdateavailable)
@@ -349,6 +350,21 @@ Get Latest bundle available from update Url
349
350
  --------------------
350
351
 
351
352
 
353
+ ### setChannel()
354
+
355
+ ```typescript
356
+ setChannel() => Promise<channelRes>
357
+ ```
358
+
359
+ Set Channel for this device
360
+
361
+ **Returns:** <code>Promise&lt;<a href="#channelres">channelRes</a>&gt;</code>
362
+
363
+ **Since:** 4.7.0
364
+
365
+ --------------------
366
+
367
+
352
368
  ### addListener('download', ...)
353
369
 
354
370
  ```typescript
@@ -606,6 +622,14 @@ removeAllListeners() => Promise<void>
606
622
  | **`url`** | <code>string</code> | | |
607
623
 
608
624
 
625
+ #### channelRes
626
+
627
+ | Prop | Type | Description | Since |
628
+ | ------------ | ------------------- | ----------------------------- | ----- |
629
+ | **`status`** | <code>string</code> | Current status of set channel | 4.7.0 |
630
+ | **`error`** | <code>any</code> | | |
631
+
632
+
609
633
  #### PluginListenerHandle
610
634
 
611
635
  | Prop | Type |
@@ -7,6 +7,7 @@ import com.android.volley.RequestQueue;
7
7
  import com.android.volley.Response;
8
8
  import com.android.volley.VolleyError;
9
9
  import com.android.volley.toolbox.JsonObjectRequest;
10
+ import com.getcapacitor.JSObject;
10
11
  import com.getcapacitor.plugin.WebView;
11
12
  import java.io.BufferedInputStream;
12
13
  import java.io.DataInputStream;
@@ -22,6 +23,7 @@ import java.net.URLConnection;
22
23
  import java.security.SecureRandom;
23
24
  import java.util.ArrayList;
24
25
  import java.util.Date;
26
+ import java.util.Iterator;
25
27
  import java.util.List;
26
28
  import java.util.zip.CRC32;
27
29
  import java.util.zip.ZipEntry;
@@ -33,6 +35,10 @@ interface Callback {
33
35
  void callback(JSONObject jsonObject);
34
36
  }
35
37
 
38
+ interface CallbackChannel {
39
+ void callback(JSObject jsoObject);
40
+ }
41
+
36
42
  public class CapacitorUpdater {
37
43
 
38
44
  private static final String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -45,7 +51,7 @@ public class CapacitorUpdater {
45
51
  private static final String bundleDirectory = "versions";
46
52
 
47
53
  public static final String TAG = "Capacitor-updater";
48
- public static final String pluginVersion = "4.6.2";
54
+ public static final String pluginVersion = "4.7.0";
49
55
 
50
56
  public SharedPreferences.Editor editor;
51
57
  public SharedPreferences prefs;
@@ -58,6 +64,7 @@ public class CapacitorUpdater {
58
64
  public String versionOs = "";
59
65
 
60
66
  public String statsUrl = "";
67
+ public String channelUrl = "";
61
68
  public String appId = "";
62
69
  public String deviceID = "";
63
70
 
@@ -104,7 +111,7 @@ public class CapacitorUpdater {
104
111
 
105
112
  if (!canonicalPath.startsWith(canonicalDir)) {
106
113
  throw new FileNotFoundException(
107
- "SecurityException, Failed to ensure directory is the start path : " + canonicalDir + " of " + canonicalPath
114
+ "SecurityException, Failed to ensure directory is the start path : " + canonicalDir + " of " + canonicalPath
108
115
  );
109
116
  }
110
117
 
@@ -372,21 +379,21 @@ public class CapacitorUpdater {
372
379
  Log.i(CapacitorUpdater.TAG, "Auto-update parameters: " + json);
373
380
  // Building a request
374
381
  JsonObjectRequest request = new JsonObjectRequest(
375
- Request.Method.POST,
376
- updateUrl,
377
- json,
378
- new Response.Listener<JSONObject>() {
379
- @Override
380
- public void onResponse(JSONObject response) {
381
- callback.callback(response);
382
+ Request.Method.POST,
383
+ updateUrl,
384
+ json,
385
+ new Response.Listener<JSONObject>() {
386
+ @Override
387
+ public void onResponse(JSONObject response) {
388
+ callback.callback(response);
389
+ }
390
+ },
391
+ new Response.ErrorListener() {
392
+ @Override
393
+ public void onErrorResponse(VolleyError error) {
394
+ Log.e(TAG, "Error getting Latest", error);
395
+ }
382
396
  }
383
- },
384
- new Response.ErrorListener() {
385
- @Override
386
- public void onErrorResponse(VolleyError error) {
387
- Log.e(TAG, "Error getting Latest", error);
388
- }
389
- }
390
397
  );
391
398
  this.requestQueue.add(request);
392
399
  } catch (JSONException ex) {
@@ -395,6 +402,61 @@ public class CapacitorUpdater {
395
402
  }
396
403
  }
397
404
 
405
+ public void setChannel(final String channel, final CallbackChannel callback) {
406
+ String channelUrl = this.channelUrl;
407
+ if (channelUrl == null || "".equals(channelUrl) || channelUrl.length() == 0) {
408
+ return;
409
+ }
410
+ try {
411
+ JSONObject json = new JSONObject();
412
+ json.put("platform", "android");
413
+ json.put("device_id", this.deviceID);
414
+ json.put("app_id", this.appId);
415
+ json.put("version_build", this.versionBuild);
416
+ json.put("version_code", this.versionCode);
417
+ json.put("version_os", this.versionOs);
418
+ json.put("version_name", this.getCurrentBundle().getVersionName());
419
+ json.put("plugin_version", pluginVersion);
420
+ json.put("channel", channel);
421
+
422
+ // Building a request
423
+ JsonObjectRequest request = new JsonObjectRequest(
424
+ Request.Method.POST,
425
+ channelUrl,
426
+ json,
427
+ new Response.Listener<JSONObject>() {
428
+ @Override
429
+ public void onResponse(JSONObject res) {
430
+ final JSObject ret = new JSObject();
431
+ Iterator<String> keys = res.keys();
432
+ while (keys.hasNext()) {
433
+ String key = keys.next();
434
+ if (res.has(key)) {
435
+ try {
436
+ ret.put(key, res.get(key));
437
+ } catch (JSONException e) {
438
+ e.printStackTrace();
439
+ }
440
+ }
441
+ }
442
+ Log.i(TAG, "Channel set to \"" + channel);
443
+ callback.callback(ret);
444
+ }
445
+ },
446
+ new Response.ErrorListener() {
447
+ @Override
448
+ public void onErrorResponse(VolleyError error) {
449
+ Log.e(TAG, "Error set channel: " + error);
450
+ }
451
+ }
452
+ );
453
+ this.requestQueue.add(request);
454
+ } catch (JSONException ex) {
455
+ // Catch if something went wrong with the params
456
+ Log.e(TAG, "Error setChannel JSONException", ex);
457
+ }
458
+ }
459
+
398
460
  public void sendStats(final String action, final String versionName) {
399
461
  String statsUrl = this.statsUrl;
400
462
  if (statsUrl == null || "".equals(statsUrl) || statsUrl.length() == 0) {
@@ -414,21 +476,21 @@ public class CapacitorUpdater {
414
476
 
415
477
  // Building a request
416
478
  JsonObjectRequest request = new JsonObjectRequest(
417
- Request.Method.POST,
418
- statsUrl,
419
- json,
420
- new Response.Listener<JSONObject>() {
421
- @Override
422
- public void onResponse(JSONObject response) {
423
- Log.i(TAG, "Stats send for \"" + action + "\", version " + versionName);
424
- }
425
- },
426
- new Response.ErrorListener() {
427
- @Override
428
- public void onErrorResponse(VolleyError error) {
429
- Log.e(TAG, "Error sending stats: " + error);
479
+ Request.Method.POST,
480
+ statsUrl,
481
+ json,
482
+ new Response.Listener<JSONObject>() {
483
+ @Override
484
+ public void onResponse(JSONObject response) {
485
+ Log.i(TAG, "Stats send for \"" + action + "\", version " + versionName);
486
+ }
487
+ },
488
+ new Response.ErrorListener() {
489
+ @Override
490
+ public void onErrorResponse(VolleyError error) {
491
+ Log.e(TAG, "Error sending stats: " + error);
492
+ }
430
493
  }
431
- }
432
494
  );
433
495
  this.requestQueue.add(request);
434
496
  } catch (JSONException ex) {
@@ -39,6 +39,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
39
39
 
40
40
  private static final String updateUrlDefault = "https://api.capgo.app/updates";
41
41
  private static final String statsUrlDefault = "https://api.capgo.app/stats";
42
+ private static final String channelUrlDefault = "https://api.capgo.app/channel_self";
42
43
 
43
44
  private static final String DELAY_CONDITION_PREFERENCES = "";
44
45
 
@@ -70,12 +71,12 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
70
71
 
71
72
  try {
72
73
  this.implementation =
73
- new CapacitorUpdater() {
74
- @Override
75
- public void notifyDownload(final String id, final int percent) {
76
- CapacitorUpdaterPlugin.this.notifyDownload(id, percent);
77
- }
78
- };
74
+ new CapacitorUpdater() {
75
+ @Override
76
+ public void notifyDownload(final String id, final int percent) {
77
+ CapacitorUpdaterPlugin.this.notifyDownload(id, percent);
78
+ }
79
+ };
79
80
  final PackageInfo pInfo = this.getContext().getPackageManager().getPackageInfo(this.getContext().getPackageName(), 0);
80
81
  this.implementation.versionBuild = pInfo.versionName;
81
82
  this.implementation.versionCode = Integer.toString(pInfo.versionCode);
@@ -92,6 +93,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
92
93
  final CapConfig config = CapConfig.loadDefault(this.getActivity());
93
94
  this.implementation.appId = config.getString("appId", "");
94
95
  this.implementation.statsUrl = this.getConfig().getString("statsUrl", statsUrlDefault);
96
+ this.implementation.channelUrl = this.getConfig().getString("channelUrl", channelUrlDefault);
95
97
  this.implementation.documentsDir = this.getContext().getFilesDir();
96
98
  this.implementation.prefs = this.prefs;
97
99
  this.implementation.editor = this.editor;
@@ -206,6 +208,35 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
206
208
  }
207
209
  }
208
210
 
211
+
212
+ @PluginMethod
213
+ public void setChannel(final PluginCall call) {
214
+ final String channel = call.getString("channel");
215
+ if (channel == null) {
216
+ Log.e(CapacitorUpdater.TAG, "setChannel called without channel");
217
+ call.reject("setChannel called without channel");
218
+ return;
219
+ }
220
+ try {
221
+ Log.i(CapacitorUpdater.TAG, "setChannel " + channel);
222
+ new Thread(
223
+ new Runnable() {
224
+ @Override
225
+ public void run() {
226
+ CapacitorUpdaterPlugin.this.implementation.setChannel(channel,
227
+ res -> {
228
+ call.resolve(res);
229
+ });
230
+ }
231
+ }
232
+ )
233
+ .start();
234
+ } catch (final Exception e) {
235
+ Log.e(CapacitorUpdater.TAG, "Failed to setChannel: " + channel, e);
236
+ call.reject("Failed to setChannel: " + channel, e);
237
+ }
238
+ }
239
+
209
240
  @PluginMethod
210
241
  public void download(final PluginCall call) {
211
242
  final String url = call.getString("url");
@@ -223,25 +254,25 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
223
254
  try {
224
255
  Log.i(CapacitorUpdater.TAG, "Downloading " + url);
225
256
  new Thread(
226
- new Runnable() {
227
- @Override
228
- public void run() {
229
- try {
230
- final BundleInfo downloaded = CapacitorUpdaterPlugin.this.implementation.download(url, version);
231
- call.resolve(downloaded.toJSON());
232
- } catch (final IOException e) {
233
- Log.e(CapacitorUpdater.TAG, "Failed to download from: " + url, e);
234
- call.reject("Failed to download from: " + url, e);
235
- final JSObject ret = new JSObject();
236
- ret.put("version", version);
237
- CapacitorUpdaterPlugin.this.notifyListeners("downloadFailed", ret);
238
- final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
239
- CapacitorUpdaterPlugin.this.implementation.sendStats("download_fail", current.getVersionName());
257
+ new Runnable() {
258
+ @Override
259
+ public void run() {
260
+ try {
261
+ final BundleInfo downloaded = CapacitorUpdaterPlugin.this.implementation.download(url, version);
262
+ call.resolve(downloaded.toJSON());
263
+ } catch (final IOException e) {
264
+ Log.e(CapacitorUpdater.TAG, "Failed to download from: " + url, e);
265
+ call.reject("Failed to download from: " + url, e);
266
+ final JSObject ret = new JSObject();
267
+ ret.put("version", version);
268
+ CapacitorUpdaterPlugin.this.notifyListeners("downloadFailed", ret);
269
+ final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
270
+ CapacitorUpdaterPlugin.this.implementation.sendStats("download_fail", current.getVersionName());
271
+ }
240
272
  }
241
273
  }
242
- }
243
274
  )
244
- .start();
275
+ .start();
245
276
  } catch (final Exception e) {
246
277
  Log.e(CapacitorUpdater.TAG, "Failed to download from: " + url, e);
247
278
  call.reject("Failed to download from: " + url, e);
@@ -366,32 +397,37 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
366
397
 
367
398
  @PluginMethod
368
399
  public void getLatest(final PluginCall call) {
369
- new Thread(
370
- new Runnable() {
371
- @Override
372
- public void run() {
373
- CapacitorUpdaterPlugin.this.implementation.getLatest(
374
- CapacitorUpdaterPlugin.this.updateUrl,
375
- res -> {
376
- Log.i(CapacitorUpdater.TAG, "Check for update via: " + CapacitorUpdaterPlugin.this.updateUrl);
377
- final JSObject ret = new JSObject();
378
- Iterator<String> keys = res.keys();
379
- while (keys.hasNext()) {
380
- String key = keys.next();
381
- if (res.has(key)) {
382
- try {
383
- ret.put(key, res.get(key));
384
- } catch (JSONException e) {
385
- e.printStackTrace();
400
+ try {
401
+ new Thread(
402
+ new Runnable() {
403
+ @Override
404
+ public void run() {
405
+ CapacitorUpdaterPlugin.this.implementation.getLatest(
406
+ CapacitorUpdaterPlugin.this.updateUrl,
407
+ res -> {
408
+ Log.i(CapacitorUpdater.TAG, "Check for update via: " + CapacitorUpdaterPlugin.this.updateUrl);
409
+ final JSObject ret = new JSObject();
410
+ Iterator<String> keys = res.keys();
411
+ while (keys.hasNext()) {
412
+ String key = keys.next();
413
+ if (res.has(key)) {
414
+ try {
415
+ ret.put(key, res.get(key));
416
+ } catch (JSONException e) {
417
+ e.printStackTrace();
418
+ }
419
+ }
386
420
  }
421
+ call.resolve(ret);
387
422
  }
388
- }
389
- call.resolve(ret);
390
- }
391
- );
392
- }
393
- }
394
- ).start();
423
+ );
424
+ }
425
+ }
426
+ ).start();
427
+ } catch (final Exception e) {
428
+ Log.e(CapacitorUpdater.TAG, "Failed to getLatest", e);
429
+ call.reject("Failed to getLatest", e);
430
+ }
395
431
  }
396
432
 
397
433
  private boolean _reset(final Boolean toLastSuccessful) {
@@ -618,159 +654,159 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
618
654
  public void onActivityStarted(@NonNull final Activity activity) {
619
655
  if (CapacitorUpdaterPlugin.this._isAutoUpdateEnabled()) {
620
656
  new Thread(
621
- new Runnable() {
622
- @Override
623
- public void run() {
624
- Log.i(CapacitorUpdater.TAG, "Check for update via: " + CapacitorUpdaterPlugin.this.updateUrl);
625
- CapacitorUpdaterPlugin.this.implementation.getLatest(
626
- CapacitorUpdaterPlugin.this.updateUrl,
627
- res -> {
628
- final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
629
- try {
630
- if (res.has("message")) {
631
- Log.i(CapacitorUpdater.TAG, "message " + res.get("message"));
632
- if (res.has("major") && res.getBoolean("major") && res.has("version")) {
633
- final JSObject majorAvailable = new JSObject();
634
- majorAvailable.put("version", res.getString("version"));
635
- CapacitorUpdaterPlugin.this.notifyListeners("majorAvailable", majorAvailable);
657
+ new Runnable() {
658
+ @Override
659
+ public void run() {
660
+ Log.i(CapacitorUpdater.TAG, "Check for update via: " + CapacitorUpdaterPlugin.this.updateUrl);
661
+ CapacitorUpdaterPlugin.this.implementation.getLatest(
662
+ CapacitorUpdaterPlugin.this.updateUrl,
663
+ res -> {
664
+ final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
665
+ try {
666
+ if (res.has("message")) {
667
+ Log.i(CapacitorUpdater.TAG, "message " + res.get("message"));
668
+ if (res.has("major") && res.getBoolean("major") && res.has("version")) {
669
+ final JSObject majorAvailable = new JSObject();
670
+ majorAvailable.put("version", res.getString("version"));
671
+ CapacitorUpdaterPlugin.this.notifyListeners("majorAvailable", majorAvailable);
672
+ }
673
+ final JSObject retNoNeed = new JSObject();
674
+ retNoNeed.put("bundle", current.toJSON());
675
+ CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
676
+ return;
636
677
  }
637
- final JSObject retNoNeed = new JSObject();
638
- retNoNeed.put("bundle", current.toJSON());
639
- CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
640
- return;
641
- }
642
678
 
643
- if (!res.has("url") || !CapacitorUpdaterPlugin.this.isValidURL(res.getString("url"))) {
644
- Log.e(CapacitorUpdater.TAG, "Error no url or wrong format");
645
- final JSObject retNoNeed = new JSObject();
646
- retNoNeed.put("bundle", current.toJSON());
647
- CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
648
- }
649
- final String latestVersionName = res.getString("version");
650
-
651
- if (
652
- latestVersionName != null &&
653
- !"".equals(latestVersionName) &&
654
- !current.getVersionName().equals(latestVersionName)
655
- ) {
656
- final BundleInfo latest =
657
- CapacitorUpdaterPlugin.this.implementation.getBundleInfoByName(latestVersionName);
658
- if (latest != null) {
659
- if (latest.isErrorStatus()) {
660
- Log.e(
661
- CapacitorUpdater.TAG,
662
- "Latest bundle already exists, and is in error state. Aborting update."
663
- );
664
- final JSObject retNoNeed = new JSObject();
665
- retNoNeed.put("bundle", current.toJSON());
666
- CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
667
- return;
668
- }
669
- if (latest.isDownloaded()) {
670
- Log.i(
671
- CapacitorUpdater.TAG,
672
- "Latest bundle already exists and download is NOT required. Update will occur next time app moves to background."
673
- );
674
- final JSObject ret = new JSObject();
675
- ret.put("bundle", latest.toJSON());
676
- CapacitorUpdaterPlugin.this.notifyListeners("updateAvailable", ret);
677
- CapacitorUpdaterPlugin.this.implementation.setNextBundle(latest.getId());
678
- return;
679
- }
680
- if (latest.isDeleted()) {
681
- Log.i(
682
- CapacitorUpdater.TAG,
683
- "Latest bundle already exists and will be deleted, download will overwrite it."
684
- );
685
- try {
686
- final Boolean deleted =
687
- CapacitorUpdaterPlugin.this.implementation.delete(latest.getId(), true);
688
- if (deleted) {
689
- Log.i(
690
- CapacitorUpdater.TAG,
691
- "Failed bundle deleted: " + latest.getVersionName()
692
- );
693
- }
694
- } catch (final IOException e) {
679
+ if (!res.has("url") || !CapacitorUpdaterPlugin.this.isValidURL(res.getString("url"))) {
680
+ Log.e(CapacitorUpdater.TAG, "Error no url or wrong format");
681
+ final JSObject retNoNeed = new JSObject();
682
+ retNoNeed.put("bundle", current.toJSON());
683
+ CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
684
+ }
685
+ final String latestVersionName = res.getString("version");
686
+
687
+ if (
688
+ latestVersionName != null &&
689
+ !"".equals(latestVersionName) &&
690
+ !current.getVersionName().equals(latestVersionName)
691
+ ) {
692
+ final BundleInfo latest =
693
+ CapacitorUpdaterPlugin.this.implementation.getBundleInfoByName(latestVersionName);
694
+ if (latest != null) {
695
+ if (latest.isErrorStatus()) {
695
696
  Log.e(
696
- CapacitorUpdater.TAG,
697
- "Failed to delete failed bundle: " + latest.getVersionName(),
698
- e
697
+ CapacitorUpdater.TAG,
698
+ "Latest bundle already exists, and is in error state. Aborting update."
699
699
  );
700
+ final JSObject retNoNeed = new JSObject();
701
+ retNoNeed.put("bundle", current.toJSON());
702
+ CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
703
+ return;
700
704
  }
701
- }
702
- }
703
-
704
- new Thread(
705
- new Runnable() {
706
- @Override
707
- public void run() {
708
- try {
709
- Log.i(
705
+ if (latest.isDownloaded()) {
706
+ Log.i(
710
707
  CapacitorUpdater.TAG,
711
- "New bundle: " +
712
- latestVersionName +
713
- " found. Current is: " +
714
- current.getVersionName() +
715
- ". Update will occur next time app moves to background."
708
+ "Latest bundle already exists and download is NOT required. Update will occur next time app moves to background."
709
+ );
710
+ final JSObject ret = new JSObject();
711
+ ret.put("bundle", latest.toJSON());
712
+ CapacitorUpdaterPlugin.this.notifyListeners("updateAvailable", ret);
713
+ CapacitorUpdaterPlugin.this.implementation.setNextBundle(latest.getId());
714
+ return;
715
+ }
716
+ if (latest.isDeleted()) {
717
+ Log.i(
718
+ CapacitorUpdater.TAG,
719
+ "Latest bundle already exists and will be deleted, download will overwrite it."
720
+ );
721
+ try {
722
+ final Boolean deleted =
723
+ CapacitorUpdaterPlugin.this.implementation.delete(latest.getId(), true);
724
+ if (deleted) {
725
+ Log.i(
726
+ CapacitorUpdater.TAG,
727
+ "Failed bundle deleted: " + latest.getVersionName()
728
+ );
729
+ }
730
+ } catch (final IOException e) {
731
+ Log.e(
732
+ CapacitorUpdater.TAG,
733
+ "Failed to delete failed bundle: " + latest.getVersionName(),
734
+ e
716
735
  );
736
+ }
737
+ }
738
+ }
717
739
 
718
- final String url = res.getString("url");
719
- final BundleInfo next =
720
- CapacitorUpdaterPlugin.this.implementation.download(url, latestVersionName);
721
- final String checksum = res.has("checksum") ? res.getString("checksum") : "";
722
- if (!checksum.equals("") && !next.getChecksum().equals(checksum)) {
723
- Log.e(
724
- CapacitorUpdater.TAG,
725
- "Error checksum " + next.getChecksum() + " " + checksum
726
- );
727
- final Boolean res =
728
- CapacitorUpdaterPlugin.this.implementation.delete(next.getId());
729
- if (res) {
740
+ new Thread(
741
+ new Runnable() {
742
+ @Override
743
+ public void run() {
744
+ try {
730
745
  Log.i(
731
- CapacitorUpdater.TAG,
732
- "Failed bundle deleted: " + next.getVersionName()
746
+ CapacitorUpdater.TAG,
747
+ "New bundle: " +
748
+ latestVersionName +
749
+ " found. Current is: " +
750
+ current.getVersionName() +
751
+ ". Update will occur next time app moves to background."
733
752
  );
753
+
754
+ final String url = res.getString("url");
755
+ final BundleInfo next =
756
+ CapacitorUpdaterPlugin.this.implementation.download(url, latestVersionName);
757
+ final String checksum = res.has("checksum") ? res.getString("checksum") : "";
758
+ if (!checksum.equals("") && !next.getChecksum().equals(checksum)) {
759
+ Log.e(
760
+ CapacitorUpdater.TAG,
761
+ "Error checksum " + next.getChecksum() + " " + checksum
762
+ );
763
+ final Boolean res =
764
+ CapacitorUpdaterPlugin.this.implementation.delete(next.getId());
765
+ if (res) {
766
+ Log.i(
767
+ CapacitorUpdater.TAG,
768
+ "Failed bundle deleted: " + next.getVersionName()
769
+ );
770
+ }
771
+ return;
772
+ }
773
+ final JSObject ret = new JSObject();
774
+ ret.put("bundle", next.toJSON());
775
+ CapacitorUpdaterPlugin.this.notifyListeners("updateAvailable", ret);
776
+ CapacitorUpdaterPlugin.this.implementation.setNextBundle(next.getId());
777
+ } catch (final Exception e) {
778
+ Log.e(CapacitorUpdater.TAG, "error downloading file", e);
779
+ final JSObject ret = new JSObject();
780
+ ret.put("version", latestVersionName);
781
+ CapacitorUpdaterPlugin.this.notifyListeners("downloadFailed", ret);
782
+ final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
783
+ CapacitorUpdaterPlugin.this.implementation.sendStats("download_fail", current.getVersionName());
784
+ final JSObject retNoNeed = new JSObject();
785
+ retNoNeed.put("bundle", current.toJSON());
786
+ CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
734
787
  }
735
- return;
736
788
  }
737
- final JSObject ret = new JSObject();
738
- ret.put("bundle", next.toJSON());
739
- CapacitorUpdaterPlugin.this.notifyListeners("updateAvailable", ret);
740
- CapacitorUpdaterPlugin.this.implementation.setNextBundle(next.getId());
741
- } catch (final Exception e) {
742
- Log.e(CapacitorUpdater.TAG, "error downloading file", e);
743
- final JSObject ret = new JSObject();
744
- ret.put("version", latestVersionName);
745
- CapacitorUpdaterPlugin.this.notifyListeners("downloadFailed", ret);
746
- final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
747
- CapacitorUpdaterPlugin.this.implementation.sendStats("download_fail", current.getVersionName());
748
- final JSObject retNoNeed = new JSObject();
749
- retNoNeed.put("bundle", current.toJSON());
750
- CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
751
789
  }
752
- }
753
- }
754
- )
755
- .start();
756
- } else {
757
- Log.i(CapacitorUpdater.TAG, "No need to update, " + current.getId() + " is the latest bundle.");
790
+ )
791
+ .start();
792
+ } else {
793
+ Log.i(CapacitorUpdater.TAG, "No need to update, " + current.getId() + " is the latest bundle.");
794
+ final JSObject retNoNeed = new JSObject();
795
+ retNoNeed.put("bundle", current.toJSON());
796
+ CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
797
+ }
798
+ } catch (final JSONException e) {
799
+ Log.e(CapacitorUpdater.TAG, "error parsing JSON", e);
758
800
  final JSObject retNoNeed = new JSObject();
759
801
  retNoNeed.put("bundle", current.toJSON());
760
802
  CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
761
803
  }
762
- } catch (final JSONException e) {
763
- Log.e(CapacitorUpdater.TAG, "error parsing JSON", e);
764
- final JSObject retNoNeed = new JSObject();
765
- retNoNeed.put("bundle", current.toJSON());
766
- CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
767
804
  }
768
- }
769
805
  );
806
+ }
770
807
  }
771
- }
772
808
  )
773
- .start();
809
+ .start();
774
810
  }
775
811
 
776
812
  this.checkAppReady();
@@ -798,21 +834,21 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
798
834
  backgroundTask.interrupt();
799
835
  }
800
836
  backgroundTask =
801
- new Thread(
802
- new Runnable() {
803
- @Override
804
- public void run() {
805
- try {
806
- Thread.sleep(timeout);
807
- taskRunning = false;
808
- _checkCancelDelay(false);
809
- installNext();
810
- } catch (InterruptedException e) {
811
- Log.i(CapacitorUpdater.TAG, "Background Task canceled, Activity resumed before timer completes");
837
+ new Thread(
838
+ new Runnable() {
839
+ @Override
840
+ public void run() {
841
+ try {
842
+ Thread.sleep(timeout);
843
+ taskRunning = false;
844
+ _checkCancelDelay(false);
845
+ installNext();
846
+ } catch (InterruptedException e) {
847
+ Log.i(CapacitorUpdater.TAG, "Background Task canceled, Activity resumed before timer completes");
848
+ }
849
+ }
812
850
  }
813
- }
814
- }
815
- );
851
+ );
816
852
  backgroundTask.start();
817
853
  } else {
818
854
  this._checkCancelDelay(false);
@@ -892,8 +928,8 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
892
928
  public void run() {
893
929
  try {
894
930
  Log.i(
895
- CapacitorUpdater.TAG,
896
- "Wait for " + CapacitorUpdaterPlugin.this.appReadyTimeout + "ms, then check for notifyAppReady"
931
+ CapacitorUpdater.TAG,
932
+ "Wait for " + CapacitorUpdaterPlugin.this.appReadyTimeout + "ms, then check for notifyAppReady"
897
933
  );
898
934
  Thread.sleep(CapacitorUpdaterPlugin.this.appReadyTimeout);
899
935
  CapacitorUpdaterPlugin.this.checkRevert();
package/dist/docs.json CHANGED
@@ -374,6 +374,31 @@
374
374
  ],
375
375
  "slug": "getlatest"
376
376
  },
377
+ {
378
+ "name": "setChannel",
379
+ "signature": "() => Promise<channelRes>",
380
+ "parameters": [],
381
+ "returns": "Promise<channelRes>",
382
+ "tags": [
383
+ {
384
+ "name": "returns",
385
+ "text": "an Promise resolved when channel is set"
386
+ },
387
+ {
388
+ "name": "throws",
389
+ "text": "An error if the something went wrong"
390
+ },
391
+ {
392
+ "name": "since",
393
+ "text": "4.7.0"
394
+ }
395
+ ],
396
+ "docs": "Set Channel for this device",
397
+ "complexTypes": [
398
+ "channelRes"
399
+ ],
400
+ "slug": "setchannel"
401
+ },
377
402
  {
378
403
  "name": "addListener",
379
404
  "signature": "(eventName: 'download', listenerFunc: DownloadChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle",
@@ -703,6 +728,7 @@
703
728
  "\"@capacitor/cli\"",
704
729
  "noNeedEvent",
705
730
  "updateAvailableEvent",
731
+ "channelRes",
706
732
  "DownloadEvent",
707
733
  "MajorAvailableEvent",
708
734
  "DownloadFailedEvent",
@@ -774,6 +800,7 @@
774
800
  "\"@capacitor/cli\"",
775
801
  "noNeedEvent",
776
802
  "updateAvailableEvent",
803
+ "channelRes",
777
804
  "DownloadEvent",
778
805
  "MajorAvailableEvent",
779
806
  "DownloadFailedEvent",
@@ -832,6 +859,7 @@
832
859
  "\"@capacitor/cli\"",
833
860
  "noNeedEvent",
834
861
  "updateAvailableEvent",
862
+ "channelRes",
835
863
  "DownloadEvent",
836
864
  "MajorAvailableEvent",
837
865
  "DownloadFailedEvent",
@@ -900,6 +928,59 @@
900
928
  "type": "string | undefined"
901
929
  }
902
930
  ],
931
+ "importObject": [
932
+ "PluginListenerHandle",
933
+ "\"@capacitor/cli\"",
934
+ "noNeedEvent",
935
+ "updateAvailableEvent",
936
+ "channelRes",
937
+ "DownloadEvent",
938
+ "MajorAvailableEvent",
939
+ "DownloadFailedEvent",
940
+ "DownloadCompleteEvent",
941
+ "UpdateFailedEvent",
942
+ "BundleInfo",
943
+ "DelayCondition",
944
+ "BundleStatus",
945
+ "DelayUntilNext",
946
+ "DownloadChangeListener",
947
+ "NoNeedListener",
948
+ "UpdateAvailabledListener",
949
+ "DownloadFailedListener",
950
+ "DownloadCompleteListener",
951
+ "MajorAvailableListener",
952
+ "UpdateFailedListener",
953
+ "AppReloadedListener",
954
+ "CapacitorUpdaterPlugin"
955
+ ]
956
+ },
957
+ {
958
+ "name": "channelRes",
959
+ "slug": "channelres",
960
+ "docs": "",
961
+ "tags": [],
962
+ "methods": [],
963
+ "properties": [
964
+ {
965
+ "name": "status",
966
+ "tags": [
967
+ {
968
+ "text": "4.7.0",
969
+ "name": "since"
970
+ }
971
+ ],
972
+ "docs": "Current status of set channel",
973
+ "complexTypes": [],
974
+ "type": "string"
975
+ },
976
+ {
977
+ "name": "error",
978
+ "tags": [],
979
+ "docs": "",
980
+ "complexTypes": [],
981
+ "type": "any"
982
+ }
983
+ ],
903
984
  "importObject": [
904
985
  "PluginListenerHandle",
905
986
  "\"@capacitor/cli\"",
@@ -910,6 +991,7 @@
910
991
  "DownloadFailedEvent",
911
992
  "DownloadCompleteEvent",
912
993
  "UpdateFailedEvent",
994
+ "latestVersion",
913
995
  "BundleInfo",
914
996
  "DelayCondition",
915
997
  "BundleStatus",
@@ -987,6 +1069,7 @@
987
1069
  "\"@capacitor/cli\"",
988
1070
  "noNeedEvent",
989
1071
  "updateAvailableEvent",
1072
+ "channelRes",
990
1073
  "MajorAvailableEvent",
991
1074
  "DownloadFailedEvent",
992
1075
  "DownloadCompleteEvent",
@@ -1033,6 +1116,7 @@
1033
1116
  "PluginListenerHandle",
1034
1117
  "\"@capacitor/cli\"",
1035
1118
  "updateAvailableEvent",
1119
+ "channelRes",
1036
1120
  "DownloadEvent",
1037
1121
  "MajorAvailableEvent",
1038
1122
  "DownloadFailedEvent",
@@ -1080,6 +1164,7 @@
1080
1164
  "PluginListenerHandle",
1081
1165
  "\"@capacitor/cli\"",
1082
1166
  "noNeedEvent",
1167
+ "channelRes",
1083
1168
  "DownloadEvent",
1084
1169
  "MajorAvailableEvent",
1085
1170
  "DownloadFailedEvent",
@@ -1128,6 +1213,7 @@
1128
1213
  "\"@capacitor/cli\"",
1129
1214
  "noNeedEvent",
1130
1215
  "updateAvailableEvent",
1216
+ "channelRes",
1131
1217
  "DownloadEvent",
1132
1218
  "MajorAvailableEvent",
1133
1219
  "DownloadFailedEvent",
@@ -1173,6 +1259,7 @@
1173
1259
  "\"@capacitor/cli\"",
1174
1260
  "noNeedEvent",
1175
1261
  "updateAvailableEvent",
1262
+ "channelRes",
1176
1263
  "DownloadEvent",
1177
1264
  "DownloadFailedEvent",
1178
1265
  "DownloadCompleteEvent",
@@ -1220,6 +1307,7 @@
1220
1307
  "\"@capacitor/cli\"",
1221
1308
  "noNeedEvent",
1222
1309
  "updateAvailableEvent",
1310
+ "channelRes",
1223
1311
  "DownloadEvent",
1224
1312
  "MajorAvailableEvent",
1225
1313
  "DownloadFailedEvent",
@@ -1265,6 +1353,7 @@
1265
1353
  "\"@capacitor/cli\"",
1266
1354
  "noNeedEvent",
1267
1355
  "updateAvailableEvent",
1356
+ "channelRes",
1268
1357
  "DownloadEvent",
1269
1358
  "MajorAvailableEvent",
1270
1359
  "DownloadCompleteEvent",
@@ -1553,6 +1642,22 @@
1553
1642
  "docs": "Configure the URL / endpoint to which update statistics are sent.\n\nOnly available for Android and iOS. Set to \"\" to disable stats reporting.",
1554
1643
  "complexTypes": [],
1555
1644
  "type": "string | undefined"
1645
+ },
1646
+ {
1647
+ "name": "allowEmulatorProd",
1648
+ "tags": [
1649
+ {
1650
+ "text": "true",
1651
+ "name": "default"
1652
+ },
1653
+ {
1654
+ "text": "false",
1655
+ "name": "example"
1656
+ }
1657
+ ],
1658
+ "docs": "Allow the plugin to automatically check for updates on app launch on emulator devices in production app.\n\nThis is useful for CI/CD who send builds to google at each commit.",
1659
+ "complexTypes": [],
1660
+ "type": "boolean | undefined"
1556
1661
  }
1557
1662
  ],
1558
1663
  "docs": "These configuration values are available:"
@@ -68,6 +68,15 @@ declare module '@capacitor/cli' {
68
68
  * @example https://example.com/api/stats
69
69
  */
70
70
  statsUrl?: string;
71
+ /**
72
+ * Allow the plugin to automatically check for updates on app launch on emulator devices in production app.
73
+ *
74
+ * This is useful for CI/CD who send builds to google at each commit.
75
+ *
76
+ * @default true
77
+ * @example false
78
+ */
79
+ allowEmulatorProd?: boolean;
71
80
  };
72
81
  }
73
82
  }
@@ -87,6 +96,15 @@ export interface updateAvailableEvent {
87
96
  */
88
97
  bundle: BundleInfo;
89
98
  }
99
+ export interface channelRes {
100
+ /**
101
+ * Current status of set channel
102
+ *
103
+ * @since 4.7.0
104
+ */
105
+ status: string;
106
+ error?: any;
107
+ }
90
108
  export interface DownloadEvent {
91
109
  /**
92
110
  * Current status of download, between 0 and 100.
@@ -301,6 +319,14 @@ export interface CapacitorUpdaterPlugin {
301
319
  * @since 4.0.0
302
320
  */
303
321
  getLatest(): Promise<latestVersion>;
322
+ /**
323
+ * Set Channel for this device
324
+ *
325
+ * @returns {Promise<channelRes>} an Promise resolved when channel is set
326
+ * @throws An error if the something went wrong
327
+ * @since 4.7.0
328
+ */
329
+ setChannel(): Promise<channelRes>;
304
330
  /**
305
331
  * Listen for download event in the App, let you know when the download is started, loading and finished
306
332
  *
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { CapacitorUpdaterPlugin, BundleInfo, latestVersion, DelayCondition } from './definitions';
2
+ import type { CapacitorUpdaterPlugin, BundleInfo, latestVersion, DelayCondition, channelRes } from './definitions';
3
3
  export declare class CapacitorUpdaterWeb extends WebPlugin implements CapacitorUpdaterPlugin {
4
4
  download(options: {
5
5
  url: string;
@@ -35,6 +35,7 @@ export declare class CapacitorUpdaterWeb extends WebPlugin implements CapacitorU
35
35
  }>;
36
36
  reload(): Promise<void>;
37
37
  getLatest(): Promise<latestVersion>;
38
+ setChannel(): Promise<channelRes>;
38
39
  notifyAppReady(): Promise<BundleInfo>;
39
40
  setMultiDelay(options: {
40
41
  delayConditions: DelayCondition[];
package/dist/esm/web.js CHANGED
@@ -56,6 +56,13 @@ export class CapacitorUpdaterWeb extends WebPlugin {
56
56
  message: 'Cannot getLatest current bundle in web',
57
57
  };
58
58
  }
59
+ async setChannel() {
60
+ console.warn('Cannot setChannel in web');
61
+ return {
62
+ status: 'error',
63
+ error: 'Cannot setChannel in web',
64
+ };
65
+ }
59
66
  async notifyAppReady() {
60
67
  console.warn('Cannot notify App Ready in web');
61
68
  return BUNDLE_BUILTIN;
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,cAAc,GAAe;IACjC,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,0BAA0B;IACtC,EAAE,EAAE,SAAS;IACb,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,KAAK,CAAC,QAAQ,CAAC,OAA0C;QACvD,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAuB;QAChC,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,OAAuB;QAC/B,OA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AgC,CAAC,CAAC;QAC/C,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,OAA8C;QAChE,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,CAAC,CAAC;QACtE,OAAO;IACT,CAAC;IACD,KAAK,CAAC,QAAQ,CAAC,MAAsB;QACnC,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO;IACT,CAAC;IACD,KAAK,CAAC,WAAW;QACf,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;CACF"}
@@ -65,6 +65,13 @@ class CapacitorUpdaterWeb extends core.WebPlugin {
65
65
  message: 'Cannot getLatest current bundle in web',
66
66
  };
67
67
  }
68
+ async setChannel() {
69
+ console.warn('Cannot setChannel in web');
70
+ return {
71
+ status: 'error',
72
+ error: 'Cannot setChannel in web',
73
+ };
74
+ }
68
75
  async notifyAppReady() {
69
76
  console.warn('Cannot notify App Ready in web');
70
77
  return BUNDLE_BUILTIN;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACvE,CAAC;;ACFD,MAAM,cAAc,GAAG;AACvB,IAAI,MAAM,EAAE,SAAS;AACrB,IAAI,OAAO,EAAE,EAAE;AACf,IAAI,UAAU,EAAE,0BAA0B;AAC1C,IAAI,EAAE,EAAE,SAAS;AACjB,IAAI,QAAQ,EAAE,EAAE;AAChB,CAAC,CAAC;AACK,MAAM,mBAAmB,SAASC,cAAS,CAAC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
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel() {\n console.warn('Cannot setChannel in web');\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACvE,CAAC;;ACFD,MAAM,cAAc,GAAG;AACvB,IAAI,MAAM,EAAE,SAAS;AACrB,IAAI,OAAO,EAAE,EAAE;AACf,IAAI,UAAU,EAAE,0BAA0B;AAC1C,IAAI,EAAE,EAAE,SAAS;AACjB,IAAI,QAAQ,EAAE,EAAE;AAChB,CAAC,CAAC;AACK,MAAM,mBAAmB,SAASC,cAAS,CAAC;AACnD,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AAChE,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK;AACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AAChE,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK;AACL,IAAI,MAAM,mBAAmB,GAAG;AAChC,QAAQ,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;AAC9D,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClC,KAAK;AACL,IAAI,MAAM,GAAG,CAAC,OAAO,EAAE;AACvB,QAAQ,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;AACjE,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,WAAW,GAAG;AACxB,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C,IAAI,CAAC,0BAA0B,CAAC,CAAC;AACjD,QAAQ,OAAO;AACf,YAAY,MAAM,EAAE,OAAO;AAC3B,YAAY,KAAK,EAAE,0BAA0B;AAC7C,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AACvD,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK;AACL,IAAI,MAAM,aAAa,CAAC,OAAO,EAAE;AACjC,QAAQ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC/H,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,QAAQ,CAAC,MAAM,EAAE;AAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AACvD,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;AAClD,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -62,6 +62,13 @@ var capacitorCapacitorUpdater = (function (exports, core) {
62
62
  message: 'Cannot getLatest current bundle in web',
63
63
  };
64
64
  }
65
+ async setChannel() {
66
+ console.warn('Cannot setChannel in web');
67
+ return {
68
+ status: 'error',
69
+ error: 'Cannot setChannel in web',
70
+ };
71
+ }
65
72
  async notifyAppReady() {
66
73
  console.warn('Cannot notify App Ready in web');
67
74
  return BUNDLE_BUILTIN;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D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K,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/H,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,QAAQ,CAAC,MAAM,EAAE;IAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;IACvD,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAClD,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel() {\n console.warn('Cannot setChannel in web');\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACvE,CAAC;;ICFD,MAAM,cAAc,GAAG;IACvB,IAAI,MAAM,EAAE,SAAS;IACrB,IAAI,OAAO,EAAE,EAAE;IACf,IAAI,UAAU,EAAE,0BAA0B;IAC1C,IAAI,EAAE,EAAE,SAAS;IACjB,IAAI,QAAQ,EAAE,EAAE;IAChB,CAAC,CAAC;IACK,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IAChE,QAAQ,OAAO,cAAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IAChE,QAAQ,OAAO,cAAc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
19
+ struct SetChannelDec: Decodable {
20
+ let status: String?
21
+ let error: String?
22
+ }
23
+ public class SetChannel: NSObject {
24
+ var status: String = ""
25
+ var error: String = ""
26
+ }
27
+ extension SetChannel {
28
+ func toDict() -> [String: Any] {
29
+ var dict = [String: Any]()
30
+ let otherSelf = Mirror(reflecting: self)
31
+ for child in otherSelf.children {
32
+ if let key = child.label {
33
+ dict[key] = child.value
34
+ }
35
+ }
36
+ return dict
37
+ }
38
+ }
19
39
  struct AppVersionDec: Decodable {
20
40
  let version: String?
21
41
  let checksum: String?
@@ -148,8 +168,9 @@ extension CustomError: LocalizedError {
148
168
 
149
169
  public let TAG = "✨ Capacitor-updater:"
150
170
  public let CAP_SERVER_PATH = "serverBasePath"
151
- public let pluginVersion = "4.6.2"
171
+ public let pluginVersion = "4.7.0"
152
172
  public var statsUrl = ""
173
+ public var channelUrl = ""
153
174
  public var appId = ""
154
175
  public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
155
176
 
@@ -457,6 +478,43 @@ extension CustomError: LocalizedError {
457
478
  self.setBundleStatus(id: bundle.getId(), status: BundleStatus.ERROR)
458
479
  }
459
480
 
481
+ func setChannel(channel: String) -> SetChannel? {
482
+ if self.channelUrl == "" {
483
+ return nil
484
+ }
485
+ let semaphore = DispatchSemaphore(value: 0)
486
+ let setChannel = SetChannel()
487
+ let parameters: [String: String] = [
488
+ "platform": "ios",
489
+ "device_id": self.deviceID,
490
+ "version_name": self.getCurrentBundle().getVersionName(),
491
+ "version_build": self.versionName,
492
+ "version_code": self.versionCode,
493
+ "version_os": self.versionOs,
494
+ "plugin_version": self.pluginVersion,
495
+ "channel": channel,
496
+ "app_id": self.appId
497
+ ]
498
+ let request = AF.request(self.channelUrl, method: .post, parameters: parameters, encoder: JSONParameterEncoder.default)
499
+
500
+ request.validate().responseDecodable(of: SetChannelDec.self) { response in
501
+ switch response.result {
502
+ case .success:
503
+ if let status = response.value?.status {
504
+ setChannel.status = status
505
+ }
506
+ if let error = response.value?.error {
507
+ setChannel.error = error
508
+ }
509
+ case let .failure(error):
510
+ print("\(self.TAG) Error set Channel", error )
511
+ }
512
+ semaphore.signal()
513
+ }
514
+ semaphore.wait()
515
+ return setChannel
516
+ }
517
+
460
518
  func sendStats(action: String, versionName: String) {
461
519
  if self.statsUrl == "" {
462
520
  return
@@ -16,6 +16,7 @@ CAP_PLUGIN(CapacitorUpdaterPlugin, "CapacitorUpdater",
16
16
  CAP_PLUGIN_METHOD(setMultiDelay, CAPPluginReturnPromise);
17
17
  CAP_PLUGIN_METHOD(cancelDelay, CAPPluginReturnPromise);
18
18
  CAP_PLUGIN_METHOD(getLatest, CAPPluginReturnPromise);
19
+ CAP_PLUGIN_METHOD(setChannel, CAPPluginReturnPromise);
19
20
  CAP_PLUGIN_METHOD(getDeviceId, CAPPluginReturnPromise);
20
21
  CAP_PLUGIN_METHOD(getPluginVersion, CAPPluginReturnPromise);
21
22
  CAP_PLUGIN_METHOD(next, CAPPluginReturnPromise);
@@ -11,6 +11,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
11
11
  private var implementation = CapacitorUpdater()
12
12
  static let updateUrlDefault = "https://api.capgo.app/updates"
13
13
  static let statsUrlDefault = "https://api.capgo.app/stats"
14
+ static let channelUrlDefault = "https://api.capgo.app/channel_self"
14
15
  let DELAY_CONDITION_PREFERENCES = ""
15
16
  private var updateUrl = ""
16
17
  private var statsUrl = ""
@@ -49,6 +50,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
49
50
  implementation.appId = config?["appId"] as! String
50
51
  }
51
52
  implementation.statsUrl = getConfig().getString("statsUrl", CapacitorUpdaterPlugin.statsUrlDefault)!
53
+ implementation.channelUrl = getConfig().getString("channelUrl", CapacitorUpdaterPlugin.channelUrlDefault)!
52
54
  if resetWhenUpdate {
53
55
  self.cleanupObsoleteVersions()
54
56
  }
@@ -234,8 +236,25 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
234
236
  }
235
237
 
236
238
  @objc func getLatest(_ call: CAPPluginCall) {
237
- let res = self.implementation.getLatest(url: URL(string: self.updateUrl)!)
238
- call.resolve(res.toDict())
239
+ DispatchQueue.global(qos: .background).async {
240
+ let res = self.implementation.getLatest(url: URL(string: self.updateUrl)!)
241
+ call.resolve(res.toDict())
242
+ }
243
+ }
244
+
245
+ @objc func setChannel(_ call: CAPPluginCall) {
246
+ guard let channel = call.getString("channel") else {
247
+ print("\(self.implementation.TAG) setChannel called without channel")
248
+ call.reject("setChannel called without channel")
249
+ return
250
+ }
251
+ DispatchQueue.global(qos: .background).async {
252
+ guard let res = self.implementation.setChannel(channel: channel) else {
253
+ call.reject("Cannot setChannel")
254
+ return
255
+ }
256
+ call.resolve(res.toDict())
257
+ }
239
258
  }
240
259
 
241
260
  @objc func _reset(toLastSuccessful: Bool) -> Bool {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "4.6.2",
3
+ "version": "4.7.0",
4
4
  "license": "LGPL-3.0-only",
5
5
  "description": "OTA update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",