@capgo/capacitor-updater 3.0.7 → 3.0.10

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.
@@ -47,7 +47,7 @@ public class CapacitorUpdater {
47
47
  public String statsUrl = "";
48
48
  public String appId = "";
49
49
  public String deviceID = "";
50
- private String pluginVersion = "3.0.7";
50
+ private String pluginVersion = "3.0.10";
51
51
 
52
52
 
53
53
  private FilenameFilter filter = new FilenameFilter() {
@@ -82,7 +82,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
82
82
  editor.putString("LatestVersionNative", currentVersionNative.toString());
83
83
  editor.commit();
84
84
  } catch (Exception ex) {
85
- Log.e("CapacitorUpdater", "Cannot get the current version" + ex.getMessage());
85
+ Log.e("CapacitorUpdater", "Cannot get the current version " + ex.getMessage());
86
86
  }
87
87
  }
88
88
  if (!autoUpdate || this.autoUpdateUrl.equals("")) return;
@@ -183,7 +183,10 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
183
183
  }
184
184
  implementation.reset();
185
185
  String pathHot = implementation.getLastPathHot();
186
- this.bridge.setServerAssetPath(pathHot);
186
+ if (this.bridge.getLocalServer() != null) {
187
+ // if the server is not ready yet, hot reload is not needed
188
+ this.bridge.setServerAssetPath(pathHot);
189
+ }
187
190
  return true;
188
191
  }
189
192
 
@@ -255,17 +258,19 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
255
258
  public void run() {
256
259
  implementation.getLatest(autoUpdateUrl, (res) -> {
257
260
  try {
258
- String currentVersion = implementation.getVersionName();
259
- String newVersion = (String) res.get("version");
260
- JSObject ret = new JSObject();
261
- ret.put("newVersion", newVersion);
262
261
  if (res.has("message")) {
263
262
  Log.i(TAG, "Capacitor-updater: " + res.get("message"));
264
- if (res.getBoolean("major")) {
263
+ if (res.has("major") && res.getBoolean("major") && res.has("version")) {
264
+ JSObject ret = new JSObject();
265
+ ret.put("newVersion", (String) res.get("version"));
265
266
  notifyListeners("majorAvailable", ret);
266
267
  }
267
268
  return;
268
269
  }
270
+ String currentVersion = implementation.getVersionName();
271
+ String newVersion = (String) res.get("version");
272
+ JSObject ret = new JSObject();
273
+ ret.put("newVersion", newVersion);
269
274
  String failingVersion = prefs.getString("failingVersion", "");
270
275
  if (!newVersion.equals("") && !newVersion.equals(failingVersion)) {
271
276
  new Thread(new Runnable(){
@@ -37,7 +37,7 @@ extension Bundle {
37
37
  public var appId = ""
38
38
  public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
39
39
  public var notifyDownload: (Int) -> Void = { _ in }
40
- public var pluginVersion = "3.0.7"
40
+ public var pluginVersion = "3.0.10"
41
41
  private var versionBuild = Bundle.main.releaseVersionNumber ?? ""
42
42
  private var lastPathHot = ""
43
43
  private var lastPathPersist = ""
@@ -32,6 +32,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
32
32
  implementation.appId = config?["appId"] as! String
33
33
  }
34
34
  implementation.statsUrl = getConfigValue("statsUrl") as? String ?? CapacitorUpdaterPlugin.statsUrlDefault
35
+ resetWhenUpdate = getConfigValue("resetWhenUpdate") as? Bool ?? true
35
36
  if (resetWhenUpdate) {
36
37
  var LatestVersionNative: Version = "0.0.0"
37
38
  do {
@@ -51,7 +52,6 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
51
52
  UserDefaults.standard.set( Bundle.main.buildVersionNumber, forKey: "LatestVersionNative")
52
53
  }
53
54
  if (!autoUpdate || autoUpdateUrl == "") { return }
54
- resetWhenUpdate = getConfigValue("resetWhenUpdate") as? Bool ?? true
55
55
  let nc = NotificationCenter.default
56
56
  nc.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
57
57
  nc.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "3.0.7",
3
+ "version": "3.0.10",
4
4
  "license": "AGPL-3.0-only",
5
5
  "description": "OTA update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",