@capgo/capacitor-updater 4.42.0 → 4.50.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.
@@ -55,7 +55,7 @@ public class CapacitorUpdaterPlugin
55
55
  private static final String channelUrlDefault =
56
56
  "https://api.capgo.app/channel_self";
57
57
 
58
- private final String PLUGIN_VERSION = "4.42.0";
58
+ private final String PLUGIN_VERSION = "4.50.0";
59
59
  private static final String DELAY_CONDITION_PREFERENCES = "";
60
60
 
61
61
  private SharedPreferences.Editor editor;
@@ -169,11 +169,12 @@ public class CapacitorUpdaterPlugin
169
169
  try {
170
170
  if (
171
171
  !"".equals(previous.getOriginalString()) &&
172
- this.currentVersionNative.getMajor() > previous.getMajor()
172
+ !this.currentVersionNative.getOriginalString()
173
+ .equals(previous.getOriginalString())
173
174
  ) {
174
175
  Log.i(
175
176
  CapacitorUpdater.TAG,
176
- "New native major version detected: " + this.currentVersionNative
177
+ "New native version detected: " + this.currentVersionNative
177
178
  );
178
179
  this.implementation.reset(true);
179
180
  final List<BundleInfo> installed = this.implementation.list();
@@ -1237,17 +1238,23 @@ public class CapacitorUpdaterPlugin
1237
1238
  }
1238
1239
 
1239
1240
  private boolean isMainActivity() {
1240
- Context mContext = this.getContext();
1241
- ActivityManager activityManager =
1242
- (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
1243
- List<ActivityManager.AppTask> runningTasks = activityManager.getAppTasks();
1244
- ActivityManager.RecentTaskInfo runningTask = runningTasks
1245
- .get(0)
1246
- .getTaskInfo();
1247
- String className = runningTask.baseIntent.getComponent().getClassName();
1248
- String runningActivity = runningTask.topActivity.getClassName();
1249
- boolean isThisAppActivity = className.equals(runningActivity);
1250
- return isThisAppActivity;
1241
+ try {
1242
+ Context mContext = this.getContext();
1243
+ ActivityManager activityManager =
1244
+ (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
1245
+ List<ActivityManager.AppTask> runningTasks =
1246
+ activityManager.getAppTasks();
1247
+ ActivityManager.RecentTaskInfo runningTask = runningTasks
1248
+ .get(0)
1249
+ .getTaskInfo();
1250
+ String className = runningTask.baseIntent.getComponent().getClassName();
1251
+ String runningActivity = runningTask.topActivity.getClassName();
1252
+ boolean isThisAppActivity = className.equals(runningActivity);
1253
+ return isThisAppActivity;
1254
+ } catch (final Exception e) {
1255
+ Log.e(CapacitorUpdater.TAG, "Error getting Main Activity", e);
1256
+ return false;
1257
+ }
1251
1258
  }
1252
1259
 
1253
1260
  @Override
@@ -78,7 +78,7 @@ import Foundation
78
78
  }
79
79
 
80
80
  public func getVersionName() -> String {
81
- return (self.version ?? "").isEmpty ? BundleInfo.ID_BUILTIN : self.version
81
+ return self.version.isEmpty ? BundleInfo.ID_BUILTIN : self.version
82
82
  }
83
83
 
84
84
  public func setVersionName(version: String) -> BundleInfo {
@@ -253,8 +253,16 @@ extension CustomError: LocalizedError {
253
253
  return String((0..<length).map { _ in letters.randomElement()! })
254
254
  }
255
255
 
256
+ private var isDevEnvironment: Bool {
257
+ #if DEBUG
258
+ return true
259
+ #else
260
+ return false
261
+ #endif
262
+ }
263
+
256
264
  private func isProd() -> Bool {
257
- return !self.isAppStoreReceiptSandbox() && !self.hasEmbeddedMobileProvision()
265
+ return !self.isDevEnvironment && !self.isAppStoreReceiptSandbox() && !self.hasEmbeddedMobileProvision()
258
266
  }
259
267
 
260
268
  // MARK: Private
@@ -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 = "4.42.0"
18
+ private let PLUGIN_VERSION: String = "4.50.0"
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"
@@ -74,7 +74,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
74
74
  } catch {
75
75
  print("\(self.implementation.TAG) Cannot get version native \(currentVersionNative)")
76
76
  }
77
- if LatestVersionNative != "0.0.0" && currentVersionNative.major > LatestVersionNative.major {
77
+ if LatestVersionNative != "0.0.0" && self.currentVersionNative.description != LatestVersionNative.description {
78
78
  _ = self._reset(toLastSuccessful: false)
79
79
  let res = implementation.list()
80
80
  res.forEach { version in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "4.42.0",
3
+ "version": "4.50.0",
4
4
  "packageManager": "pnpm@8.2.0",
5
5
  "license": "MPL-2.0",
6
6
  "description": "Live update for capacitor apps",
@@ -64,14 +64,14 @@
64
64
  "@types/node": "^18.15.11",
65
65
  "@typescript-eslint/eslint-plugin": "^5.58.0",
66
66
  "@typescript-eslint/parser": "^5.58.0",
67
- "eslint": "^8.38.0",
67
+ "eslint": "^8.39.0",
68
68
  "eslint-plugin-import": "^2.27.5",
69
69
  "prettier": "^2.8.7",
70
70
  "prettier-plugin-java": "^2.1.0",
71
71
  "rimraf": "^4.4.1",
72
- "rollup": "^3.20.2",
72
+ "rollup": "^3.20.7",
73
73
  "swiftlint": "^1.0.1",
74
- "typescript": "^5.0.0"
74
+ "typescript": "^5.0.4"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@capacitor/core": "^4.0.0 || ^5.0.0"