@capgo/capacitor-updater 5.2.7 → 5.2.9

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.
@@ -15,6 +15,7 @@ import android.content.pm.PackageInfo;
15
15
  import android.content.pm.PackageManager;
16
16
  import android.os.Build;
17
17
  import android.os.Bundle;
18
+ import android.os.Handler;
18
19
  import android.util.Log;
19
20
  import androidx.annotation.NonNull;
20
21
  import androidx.annotation.Nullable;
@@ -55,7 +56,7 @@ public class CapacitorUpdaterPlugin
55
56
  private static final String channelUrlDefault =
56
57
  "https://api.capgo.app/channel_self";
57
58
 
58
- private final String PLUGIN_VERSION = "5.2.7";
59
+ private final String PLUGIN_VERSION = "5.2.9";
59
60
  private static final String DELAY_CONDITION_PREFERENCES = "";
60
61
 
61
62
  private SharedPreferences.Editor editor;
@@ -870,7 +871,7 @@ public class CapacitorUpdaterPlugin
870
871
  if (res.has("message")) {
871
872
  Log.i(
872
873
  CapacitorUpdater.TAG,
873
- "message " + res.get("message")
874
+ "API message " + res.get("message")
874
875
  );
875
876
  if (
876
877
  res.has("major") &&
@@ -1237,9 +1238,19 @@ public class CapacitorUpdaterPlugin
1237
1238
  this.backgroundDownload();
1238
1239
  } else {
1239
1240
  Log.i(CapacitorUpdater.TAG, "Auto update is disabled");
1240
- final JSObject ret = new JSObject();
1241
- ret.put("bundle", current.toJSON());
1242
- CapacitorUpdaterPlugin.this.notifyListeners("appReady", ret);
1241
+ // run after 1.5 s to make sure the listeners are registered
1242
+ new Handler()
1243
+ .postDelayed(
1244
+ new Runnable() {
1245
+ @Override
1246
+ public void run() {
1247
+ final JSObject ret = new JSObject();
1248
+ ret.put("bundle", current.toJSON());
1249
+ CapacitorUpdaterPlugin.this.notifyListeners("appReady", ret);
1250
+ }
1251
+ },
1252
+ 1500
1253
+ );
1243
1254
  }
1244
1255
  this.checkAppReady();
1245
1256
  }
@@ -15,7 +15,7 @@ import Version
15
15
  @objc(CapacitorUpdaterPlugin)
16
16
  public class CapacitorUpdaterPlugin: CAPPlugin {
17
17
  private var implementation = CapacitorUpdater()
18
- private let PLUGIN_VERSION: String = "5.2.7"
18
+ private let PLUGIN_VERSION: String = "5.2.9"
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"
@@ -511,11 +511,12 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
511
511
  let current = self.implementation.getCurrentBundle()
512
512
 
513
513
  if (res.message) != nil {
514
- print("\(self.implementation.TAG) message \(res.message ?? "")")
514
+ print("\(self.implementation.TAG) API message \(res.message ?? "")")
515
515
  if res.major == true {
516
516
  self.notifyListeners("majorAvailable", data: ["version": res.version])
517
517
  }
518
518
  self.notifyListeners("noNeedUpdate", data: ["bundle": current.toJSON()])
519
+ self.notifyListeners("appReady", data: ["bundle": current.toJSON()])
519
520
  self.endBackGroundTask()
520
521
  return
521
522
  }
@@ -523,6 +524,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
523
524
  guard let downloadUrl = URL(string: res.url) else {
524
525
  print("\(self.implementation.TAG) Error no url or wrong format")
525
526
  self.notifyListeners("noNeedUpdate", data: ["bundle": current.toJSON()])
527
+ self.notifyListeners("appReady", data: ["bundle": current.toJSON()])
526
528
  self.endBackGroundTask()
527
529
  return
528
530
  }
@@ -547,12 +549,14 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
547
549
  print("\(self.implementation.TAG) Error downloading file")
548
550
  self.notifyListeners("downloadFailed", data: ["version": latestVersionName])
549
551
  self.notifyListeners("noNeedUpdate", data: ["bundle": current.toJSON()])
552
+ self.notifyListeners("appReady", data: ["bundle": current.toJSON()])
550
553
  self.endBackGroundTask()
551
554
  return
552
555
  }
553
556
  if next.isErrorStatus() {
554
557
  print("\(self.implementation.TAG) Latest version is in error state. Aborting update.")
555
558
  self.notifyListeners("noNeedUpdate", data: ["bundle": current.toJSON()])
559
+ self.notifyListeners("appReady", data: ["bundle": current.toJSON()])
556
560
  self.endBackGroundTask()
557
561
  return
558
562
  }
@@ -646,7 +650,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
646
650
  self.backgroundDownload()
647
651
  } else {
648
652
  print("\(self.implementation.TAG) Auto update is disabled")
649
- self.notifyListeners("appReady", data: ["bundle": current.toJSON()])
653
+ // run after 1 second to make sure that the app is ready
654
+ DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
655
+ self.notifyListeners("appReady", data: ["bundle": current.toJSON()])
656
+ }
650
657
  }
651
658
  self.checkAppReady()
652
659
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "5.2.7",
3
+ "version": "5.2.9",
4
4
  "packageManager": "pnpm@8.6.12",
5
5
  "license": "MPL-2.0",
6
6
  "description": "Live update for capacitor apps",