@capgo/capacitor-updater 8.42.11 → 8.42.12

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.
@@ -84,7 +84,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
84
84
  private static final String[] BREAKING_EVENT_NAMES = { "breakingAvailable", "majorAvailable" };
85
85
  private static final String LAST_FAILED_BUNDLE_PREF_KEY = "CapacitorUpdater.lastFailedBundle";
86
86
 
87
- private final String pluginVersion = "8.42.11";
87
+ private final String pluginVersion = "8.42.12";
88
88
  private static final String DELAY_CONDITION_PREFERENCES = "";
89
89
 
90
90
  private SharedPreferences.Editor editor;
@@ -235,23 +235,35 @@ public class CapacitorUpdaterPlugin extends Plugin {
235
235
  this.implementation = new CapgoUpdater(logger) {
236
236
  @Override
237
237
  public void notifyDownload(final String id, final int percent) {
238
- activity.runOnUiThread(() -> {
239
- CapacitorUpdaterPlugin.this.notifyDownload(id, percent);
240
- });
238
+ if (activity != null) {
239
+ activity.runOnUiThread(() -> {
240
+ CapacitorUpdaterPlugin.this.notifyDownload(id, percent);
241
+ });
242
+ } else {
243
+ logger.warn("notifyDownload: Activity is null, skipping notification");
244
+ }
241
245
  }
242
246
 
243
247
  @Override
244
248
  public void directUpdateFinish(final BundleInfo latest) {
245
- activity.runOnUiThread(() -> {
246
- CapacitorUpdaterPlugin.this.directUpdateFinish(latest);
247
- });
249
+ if (activity != null) {
250
+ activity.runOnUiThread(() -> {
251
+ CapacitorUpdaterPlugin.this.directUpdateFinish(latest);
252
+ });
253
+ } else {
254
+ logger.warn("directUpdateFinish: Activity is null, skipping notification");
255
+ }
248
256
  }
249
257
 
250
258
  @Override
251
259
  public void notifyListeners(final String id, final Map<String, Object> res) {
252
- activity.runOnUiThread(() -> {
253
- CapacitorUpdaterPlugin.this.notifyListeners(id, CapacitorUpdaterPlugin.this.mapToJSObject(res));
254
- });
260
+ if (activity != null) {
261
+ activity.runOnUiThread(() -> {
262
+ CapacitorUpdaterPlugin.this.notifyListeners(id, CapacitorUpdaterPlugin.this.mapToJSObject(res));
263
+ });
264
+ } else {
265
+ logger.warn("notifyListeners: Activity is null, skipping notification for event: " + id);
266
+ }
255
267
  }
256
268
  };
257
269
  final PackageInfo pInfo = this.getContext().getPackageManager().getPackageInfo(this.getContext().getPackageName(), 0);
@@ -2139,6 +2151,19 @@ public class CapacitorUpdaterPlugin extends Plugin {
2139
2151
  }
2140
2152
 
2141
2153
  public void appMovedToForeground() {
2154
+ // Ensure activity reference is up-to-date before proceeding
2155
+ // This is critical for callbacks that may be invoked during background operations
2156
+ try {
2157
+ Activity currentActivity = this.getActivity();
2158
+ if (currentActivity != null) {
2159
+ CapacitorUpdaterPlugin.this.implementation.activity = currentActivity;
2160
+ } else {
2161
+ logger.warn("appMovedToForeground: Activity is null, operations may be limited");
2162
+ }
2163
+ } catch (Exception e) {
2164
+ logger.error("appMovedToForeground: Failed to update activity reference: " + e.getMessage());
2165
+ }
2166
+
2142
2167
  final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
2143
2168
  CapacitorUpdaterPlugin.this.implementation.sendStats("app_moved_to_foreground", current.getVersionName());
2144
2169
  this.delayUpdateUtils.checkCancelDelay(DelayUpdateUtils.CancelDelaySource.FOREGROUND);
@@ -2162,6 +2187,18 @@ public class CapacitorUpdaterPlugin extends Plugin {
2162
2187
  // Reset timeout flag at start of each background cycle
2163
2188
  this.autoSplashscreenTimedOut = false;
2164
2189
 
2190
+ // Ensure activity reference is up-to-date before proceeding
2191
+ try {
2192
+ Activity currentActivity = this.getActivity();
2193
+ if (currentActivity != null) {
2194
+ CapacitorUpdaterPlugin.this.implementation.activity = currentActivity;
2195
+ } else {
2196
+ logger.warn("appMovedToBackground: Activity is null, operations may be limited");
2197
+ }
2198
+ } catch (Exception e) {
2199
+ logger.error("appMovedToBackground: Failed to update activity reference: " + e.getMessage());
2200
+ }
2201
+
2165
2202
  final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
2166
2203
 
2167
2204
  // Show splashscreen FIRST, before any other background work to ensure launcher shows it
@@ -71,7 +71,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
71
71
  CAPPluginMethod(name: "completeFlexibleUpdate", returnType: CAPPluginReturnPromise)
72
72
  ]
73
73
  public var implementation = CapgoUpdater()
74
- private let pluginVersion: String = "8.42.11"
74
+ private let pluginVersion: String = "8.42.12"
75
75
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
76
76
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
77
77
  static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "8.42.11",
3
+ "version": "8.42.12",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",