@capgo/capacitor-updater 8.51.4 → 8.51.6

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.
@@ -793,8 +793,20 @@ public class ShakeMenu implements ShakeDetector.Listener, ThreeFingerPinchDetect
793
793
 
794
794
  String latestUrl = getString(latestRes, "url");
795
795
 
796
- // Check if there's an actual update available
797
- if ("up_to_date".equals(latestKind) || latestUrl == null || latestUrl.isEmpty()) {
796
+ Object manifestObj = latestRes.get("manifest");
797
+ JSONArray manifestArray = null;
798
+ if (manifestObj instanceof JSONArray) {
799
+ manifestArray = (JSONArray) manifestObj;
800
+ } else if (manifestObj instanceof List) {
801
+ manifestArray = new JSONArray((List<?>) manifestObj);
802
+ }
803
+ final boolean hasManifest = manifestArray != null && manifestArray.length() > 0;
804
+
805
+ // Check if there's an actual update available. A manifest-only
806
+ // response legitimately has no URL (the files come from the
807
+ // manifest, not a zip), so only report "already on latest" when
808
+ // the URL is empty AND there is no manifest to download from.
809
+ if ("up_to_date".equals(latestKind) || ((latestUrl == null || latestUrl.isEmpty()) && !hasManifest)) {
798
810
  activity.runOnUiThread(() -> {
799
811
  progressDialog.dismiss();
800
812
  showSuccess("Channel set to " + channelName + ". Already on latest version.");
@@ -817,25 +829,18 @@ public class ShakeMenu implements ShakeDetector.Listener, ThreeFingerPinchDetect
817
829
 
818
830
  String sessionKey = getString(latestRes, "sessionKey");
819
831
  String checksum = getString(latestRes, "checksum");
820
- Object manifestObj = latestRes.get("manifest");
832
+
833
+ // A manifest-only response has no zip URL; downloadManifest
834
+ // tolerates the placeholder URL the plugin already uses.
835
+ final String downloadUrl =
836
+ latestUrl == null || latestUrl.isEmpty() ? "https://404.capgo.app/no.zip" : latestUrl;
821
837
 
822
838
  // Download the update
823
839
  try {
824
840
  BundleInfo bundle;
825
- if (manifestObj != null) {
826
- JSONArray manifestArray = null;
827
- if (manifestObj instanceof JSONArray) {
828
- manifestArray = (JSONArray) manifestObj;
829
- } else if (manifestObj instanceof List) {
830
- manifestArray = new JSONArray((List<?>) manifestObj);
831
- }
832
-
833
- if (manifestArray == null) {
834
- throw new IllegalArgumentException("Invalid manifest format");
835
- }
836
-
841
+ if (hasManifest) {
837
842
  bundle = updater.downloadManifest(
838
- latestUrl,
843
+ downloadUrl,
839
844
  versionForUi,
840
845
  sessionKey != null ? sessionKey : "",
841
846
  checksum != null ? checksum : "",
@@ -843,7 +848,7 @@ public class ShakeMenu implements ShakeDetector.Listener, ThreeFingerPinchDetect
843
848
  );
844
849
  } else {
845
850
  bundle = updater.download(
846
- latestUrl,
851
+ downloadUrl,
847
852
  versionForUi,
848
853
  sessionKey != null ? sessionKey : "",
849
854
  checksum != null ? checksum : ""
@@ -92,7 +92,11 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
92
92
  CAPPluginMethod(name: "completeFlexibleUpdate", returnType: CAPPluginReturnPromise)
93
93
  ]
94
94
  public var implementation = CapgoUpdater()
95
- private let pluginVersion: String = "8.51.4"
95
+
96
+ deinit {
97
+ implementation.shutdown()
98
+ }
99
+ private let pluginVersion: String = "8.51.6"
96
100
  private let launchStartedAtMs = Int64(Date().timeIntervalSince1970 * 1000)
97
101
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
98
102
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
@@ -353,6 +357,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
353
357
  logger.info("Loaded persisted channelUrl")
354
358
  }
355
359
  }
360
+ implementation.restorePendingStats()
356
361
 
357
362
  let nativeBuildVersionChanged = self.hasNativeBuildVersionChanged()
358
363
  let defaultChannelPersistenceDisabled = !persistDefaultChannelOnReinstall
@@ -4616,6 +4621,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
4616
4621
 
4617
4622
  let current: BundleInfo = self.implementation.getCurrentBundle()
4618
4623
  self.implementation.sendStats(action: "app_moved_to_background", versionName: current.getVersionName())
4624
+ self.implementation.persistPendingStats()
4619
4625
  logger.info("Check for pending update")
4620
4626
 
4621
4627
  // Show splashscreen only if autoSplashscreen is enabled AND autoUpdate is enabled AND directUpdate would be used