@capgo/capacitor-updater 7.18.14 → 7.19.1

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.
package/README.md CHANGED
@@ -228,37 +228,39 @@ Capacitor Updater works by unzipping a compiled app bundle to the native device
228
228
 
229
229
  CapacitorUpdater can be configured with these options:
230
230
 
231
- | Prop | Type | Description | Default | Since |
232
- | ---------------------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------- |
233
- | **`appReadyTimeout`** | <code>number</code> | Configure the number of milliseconds the native plugin should wait before considering an update 'failed'. Only available for Android and iOS. | <code>10000 // (10 seconds)</code> | |
234
- | **`responseTimeout`** | <code>number</code> | Configure the number of seconds the native plugin should wait before considering API timeout. Only available for Android and iOS. | <code>20 // (20 second)</code> | |
235
- | **`autoDeleteFailed`** | <code>boolean</code> | Configure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS. | <code>true</code> | |
236
- | **`autoDeletePrevious`** | <code>boolean</code> | Configure whether the plugin should use automatically delete previous bundles after a successful update. Only available for Android and iOS. | <code>true</code> | |
237
- | **`autoUpdate`** | <code>boolean</code> | Configure whether the plugin should use Auto Update via an update server. Only available for Android and iOS. | <code>true</code> | |
238
- | **`resetWhenUpdate`** | <code>boolean</code> | Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device. Only available for Android and iOS. | <code>true</code> | |
239
- | **`updateUrl`** | <code>string</code> | Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS. | <code>https://plugin.capgo.app/updates</code> | |
240
- | **`channelUrl`** | <code>string</code> | Configure the URL / endpoint for channel operations. Only available for Android and iOS. | <code>https://plugin.capgo.app/channel_self</code> | |
241
- | **`statsUrl`** | <code>string</code> | Configure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting. | <code>https://plugin.capgo.app/stats</code> | |
242
- | **`publicKey`** | <code>string</code> | Configure the public key for end to end live update encryption Version 2 Only available for Android and iOS. | <code>undefined</code> | 6.2.0 |
243
- | **`version`** | <code>string</code> | Configure the current version of the app. This will be used for the first update request. If not set, the plugin will get the version from the native code. Only available for Android and iOS. | <code>undefined</code> | 4.17.48 |
244
- | **`directUpdate`** | <code>boolean \| 'always' \| 'atInstall'</code> | Configure when the plugin should direct install updates. Only for autoUpdate mode. Works well for apps less than 10MB and with uploads done using --partial flag. Zip or apps more than 10MB will be relatively slow for users to update. - false: Never do direct updates (default behavior) - atInstall: Direct update only when app is installed/updated from store, otherwise use normal background update - always: Always do direct updates immediately when available - true: (deprecated) Same as "always" for backward compatibility Only available for Android and iOS. | <code>false</code> | 5.1.0 |
245
- | **`autoSplashscreen`** | <code>boolean</code> | Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed. This removes the need to manually listen for appReady events and call SplashScreen.hide(). Only works when directUpdate is set to "atInstall", "always", or true. Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false. Requires autoUpdate and directUpdate to be enabled. Only available for Android and iOS. | <code>false</code> | 7.6.0 |
246
- | **`periodCheckDelay`** | <code>number</code> | Configure the delay period for period update check. the unit is in seconds. Only available for Android and iOS. Cannot be less than 600 seconds (10 minutes). | <code>0 (disabled)</code> | |
247
- | **`localS3`** | <code>boolean</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
248
- | **`localHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
249
- | **`localWebHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
250
- | **`localSupa`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
251
- | **`localSupaAnon`** | <code>string</code> | Configure the CLI to use a local server for testing. | <code>undefined</code> | 4.17.48 |
252
- | **`localApi`** | <code>string</code> | Configure the CLI to use a local api for testing. | <code>undefined</code> | 6.3.3 |
253
- | **`localApiFiles`** | <code>string</code> | Configure the CLI to use a local file api for testing. | <code>undefined</code> | 6.3.3 |
254
- | **`allowModifyUrl`** | <code>boolean</code> | Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side. | <code>false</code> | 5.4.0 |
255
- | **`allowModifyAppId`** | <code>boolean</code> | Allow the plugin to modify the appId dynamically from the JavaScript side. | <code>false</code> | 7.14.0 |
256
- | **`persistCustomId`** | <code>boolean</code> | Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts. Only available for Android and iOS. | <code>false (will be true by default in a future major release v8.x.x)</code> | 7.17.3 |
257
- | **`defaultChannel`** | <code>string</code> | Set the default channel for the app in the config. Case sensitive. This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud. This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options | <code>undefined</code> | 5.5.0 |
258
- | **`appId`** | <code>string</code> | Configure the app id for the app in the config. | <code>undefined</code> | 6.0.0 |
259
- | **`keepUrlPathAfterReload`** | <code>boolean</code> | Configure the plugin to keep the URL path after a reload. WARNING: When a reload is triggered, 'window.history' will be cleared. | <code>false</code> | 6.8.0 |
260
- | **`disableJSLogging`** | <code>boolean</code> | Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done | <code>false</code> | 7.3.0 |
261
- | **`shakeMenu`** | <code>boolean</code> | Enable shake gesture to show update menu for debugging/testing purposes | <code>false</code> | 7.5.0 |
231
+ | Prop | Type | Description | Default | Since |
232
+ | ----------------------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------- |
233
+ | **`appReadyTimeout`** | <code>number</code> | Configure the number of milliseconds the native plugin should wait before considering an update 'failed'. Only available for Android and iOS. | <code>10000 // (10 seconds)</code> | |
234
+ | **`responseTimeout`** | <code>number</code> | Configure the number of seconds the native plugin should wait before considering API timeout. Only available for Android and iOS. | <code>20 // (20 second)</code> | |
235
+ | **`autoDeleteFailed`** | <code>boolean</code> | Configure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS. | <code>true</code> | |
236
+ | **`autoDeletePrevious`** | <code>boolean</code> | Configure whether the plugin should use automatically delete previous bundles after a successful update. Only available for Android and iOS. | <code>true</code> | |
237
+ | **`autoUpdate`** | <code>boolean</code> | Configure whether the plugin should use Auto Update via an update server. Only available for Android and iOS. | <code>true</code> | |
238
+ | **`resetWhenUpdate`** | <code>boolean</code> | Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device. Only available for Android and iOS. | <code>true</code> | |
239
+ | **`updateUrl`** | <code>string</code> | Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS. | <code>https://plugin.capgo.app/updates</code> | |
240
+ | **`channelUrl`** | <code>string</code> | Configure the URL / endpoint for channel operations. Only available for Android and iOS. | <code>https://plugin.capgo.app/channel_self</code> | |
241
+ | **`statsUrl`** | <code>string</code> | Configure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting. | <code>https://plugin.capgo.app/stats</code> | |
242
+ | **`publicKey`** | <code>string</code> | Configure the public key for end to end live update encryption Version 2 Only available for Android and iOS. | <code>undefined</code> | 6.2.0 |
243
+ | **`version`** | <code>string</code> | Configure the current version of the app. This will be used for the first update request. If not set, the plugin will get the version from the native code. Only available for Android and iOS. | <code>undefined</code> | 4.17.48 |
244
+ | **`directUpdate`** | <code>boolean \| 'always' \| 'atInstall'</code> | Configure when the plugin should direct install updates. Only for autoUpdate mode. Works well for apps less than 10MB and with uploads done using --partial flag. Zip or apps more than 10MB will be relatively slow for users to update. - false: Never do direct updates (default behavior) - atInstall: Direct update only when app is installed/updated from store, otherwise use normal background update - always: Always do direct updates immediately when available - true: (deprecated) Same as "always" for backward compatibility Only available for Android and iOS. | <code>false</code> | 5.1.0 |
245
+ | **`autoSplashscreen`** | <code>boolean</code> | Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed. This removes the need to manually listen for appReady events and call SplashScreen.hide(). Only works when directUpdate is set to "atInstall", "always", or true. Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false. Requires autoUpdate and directUpdate to be enabled. Only available for Android and iOS. | <code>false</code> | 7.6.0 |
246
+ | **`autoSplashscreenLoader`** | <code>boolean</code> | Display a native loading indicator on top of the splashscreen while automatic direct updates are running. Only takes effect when {@link autoSplashscreen} is enabled. Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false. Only available for Android and iOS. | <code>false</code> | 7.19.0 |
247
+ | **`autoSplashscreenTimeout`** | <code>number</code> | Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates. If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed. Set to `0` (zero) to disable the timeout. When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch. Requires {@link autoSplashscreen} to be enabled. Only available for Android and iOS. | <code>10000 // (10 seconds)</code> | 7.19.0 |
248
+ | **`periodCheckDelay`** | <code>number</code> | Configure the delay period for period update check. the unit is in seconds. Only available for Android and iOS. Cannot be less than 600 seconds (10 minutes). | <code>0 (disabled)</code> | |
249
+ | **`localS3`** | <code>boolean</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
250
+ | **`localHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
251
+ | **`localWebHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
252
+ | **`localSupa`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
253
+ | **`localSupaAnon`** | <code>string</code> | Configure the CLI to use a local server for testing. | <code>undefined</code> | 4.17.48 |
254
+ | **`localApi`** | <code>string</code> | Configure the CLI to use a local api for testing. | <code>undefined</code> | 6.3.3 |
255
+ | **`localApiFiles`** | <code>string</code> | Configure the CLI to use a local file api for testing. | <code>undefined</code> | 6.3.3 |
256
+ | **`allowModifyUrl`** | <code>boolean</code> | Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side. | <code>false</code> | 5.4.0 |
257
+ | **`allowModifyAppId`** | <code>boolean</code> | Allow the plugin to modify the appId dynamically from the JavaScript side. | <code>false</code> | 7.14.0 |
258
+ | **`persistCustomId`** | <code>boolean</code> | Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts. Only available for Android and iOS. | <code>false (will be true by default in a future major release v8.x.x)</code> | 7.17.3 |
259
+ | **`defaultChannel`** | <code>string</code> | Set the default channel for the app in the config. Case sensitive. This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud. This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options | <code>undefined</code> | 5.5.0 |
260
+ | **`appId`** | <code>string</code> | Configure the app id for the app in the config. | <code>undefined</code> | 6.0.0 |
261
+ | **`keepUrlPathAfterReload`** | <code>boolean</code> | Configure the plugin to keep the URL path after a reload. WARNING: When a reload is triggered, 'window.history' will be cleared. | <code>false</code> | 6.8.0 |
262
+ | **`disableJSLogging`** | <code>boolean</code> | Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done | <code>false</code> | 7.3.0 |
263
+ | **`shakeMenu`** | <code>boolean</code> | Enable shake gesture to show update menu for debugging/testing purposes | <code>false</code> | 7.5.0 |
262
264
 
263
265
  ### Examples
264
266
 
@@ -281,6 +283,8 @@ In `capacitor.config.json`:
281
283
  "version": undefined,
282
284
  "directUpdate": undefined,
283
285
  "autoSplashscreen": undefined,
286
+ "autoSplashscreenLoader": undefined,
287
+ "autoSplashscreenTimeout": undefined,
284
288
  "periodCheckDelay": 3600 (1 hour),
285
289
  "localS3": undefined,
286
290
  "localHost": undefined,
@@ -325,6 +329,8 @@ const config: CapacitorConfig = {
325
329
  version: undefined,
326
330
  directUpdate: undefined,
327
331
  autoSplashscreen: undefined,
332
+ autoSplashscreenLoader: undefined,
333
+ autoSplashscreenTimeout: undefined,
328
334
  periodCheckDelay: 3600 (1 hour),
329
335
  localS3: undefined,
330
336
  localHost: undefined,
@@ -49,7 +49,7 @@ repositories {
49
49
 
50
50
 
51
51
  dependencies {
52
- def work_version = "2.10.4"
52
+ def work_version = "2.10.5"
53
53
  implementation "androidx.work:work-runtime:$work_version"
54
54
  implementation "com.google.android.gms:play-services-tasks:18.2.1"
55
55
  implementation "com.google.guava:guava:33.4.8-android"
@@ -12,8 +12,15 @@ import android.content.Context;
12
12
  import android.content.SharedPreferences;
13
13
  import android.content.pm.PackageInfo;
14
14
  import android.content.pm.PackageManager;
15
+ import android.graphics.Color;
15
16
  import android.os.Build;
17
+ import android.os.Handler;
16
18
  import android.os.Looper;
19
+ import android.view.Gravity;
20
+ import android.view.View;
21
+ import android.view.ViewGroup;
22
+ import android.widget.FrameLayout;
23
+ import android.widget.ProgressBar;
17
24
  import com.getcapacitor.CapConfig;
18
25
  import com.getcapacitor.JSArray;
19
26
  import com.getcapacitor.JSObject;
@@ -58,7 +65,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
58
65
  private static final String channelUrlDefault = "https://plugin.capgo.app/channel_self";
59
66
  private static final String CUSTOM_ID_PREF_KEY = "CapacitorUpdater.customId";
60
67
 
61
- private final String PLUGIN_VERSION = "7.18.14";
68
+ private final String PLUGIN_VERSION = "7.19.1";
62
69
  private static final String DELAY_CONDITION_PREFERENCES = "";
63
70
 
64
71
  private SharedPreferences.Editor editor;
@@ -79,6 +86,9 @@ public class CapacitorUpdaterPlugin extends Plugin {
79
86
  private Boolean taskRunning = false;
80
87
  private Boolean keepUrlPathAfterReload = false;
81
88
  private Boolean autoSplashscreen = false;
89
+ private Boolean autoSplashscreenLoader = false;
90
+ private Integer autoSplashscreenTimeout = 10000;
91
+ private Boolean autoSplashscreenTimedOut = false;
82
92
  private String directUpdateMode = "false";
83
93
  private Boolean wasRecentlyInstalledOrUpdated = false;
84
94
  Boolean shakeMenuEnabled = false;
@@ -96,6 +106,9 @@ public class CapacitorUpdaterPlugin extends Plugin {
96
106
  private DelayUpdateUtils delayUpdateUtils;
97
107
 
98
108
  private ShakeMenu shakeMenu;
109
+ private final Handler mainHandler = new Handler(Looper.getMainLooper());
110
+ private FrameLayout splashscreenLoaderOverlay;
111
+ private Runnable splashscreenTimeoutRunnable;
99
112
 
100
113
  private JSObject mapToJSObject(Map<String, Object> map) {
101
114
  JSObject jsObject = new JSObject();
@@ -252,6 +265,9 @@ public class CapacitorUpdaterPlugin extends Plugin {
252
265
  this.appReadyTimeout = this.getConfig().getInt("appReadyTimeout", 10000);
253
266
  this.keepUrlPathAfterReload = this.getConfig().getBoolean("keepUrlPathAfterReload", false);
254
267
  this.autoSplashscreen = this.getConfig().getBoolean("autoSplashscreen", false);
268
+ this.autoSplashscreenLoader = this.getConfig().getBoolean("autoSplashscreenLoader", false);
269
+ int splashscreenTimeoutValue = this.getConfig().getInt("autoSplashscreenTimeout", 10000);
270
+ this.autoSplashscreenTimeout = Math.max(0, splashscreenTimeoutValue);
255
271
  this.implementation.timeout = this.getConfig().getInt("responseTimeout", 20) * 1000;
256
272
  this.shakeMenuEnabled = this.getConfig().getBoolean("shakeMenu", false);
257
273
  boolean resetWhenUpdate = this.getConfig().getBoolean("resetWhenUpdate", true);
@@ -311,7 +327,23 @@ public class CapacitorUpdaterPlugin extends Plugin {
311
327
  }
312
328
 
313
329
  private void hideSplashscreen() {
330
+ if (Looper.myLooper() == Looper.getMainLooper()) {
331
+ hideSplashscreenInternal();
332
+ } else {
333
+ this.mainHandler.post(this::hideSplashscreenInternal);
334
+ }
335
+ }
336
+
337
+ private void hideSplashscreenInternal() {
338
+ cancelSplashscreenTimeout();
339
+ removeSplashscreenLoader();
340
+
314
341
  try {
342
+ if (getBridge() == null) {
343
+ logger.warn("Bridge not ready for hiding splashscreen with autoSplashscreen");
344
+ return;
345
+ }
346
+
315
347
  // Try to call the SplashScreen plugin directly through the bridge
316
348
  PluginHandle splashScreenPlugin = getBridge().getPlugin("SplashScreen");
317
349
  if (splashScreenPlugin != null) {
@@ -349,53 +381,135 @@ public class CapacitorUpdaterPlugin extends Plugin {
349
381
  }
350
382
 
351
383
  private void showSplashscreen() {
384
+ if (Looper.myLooper() == Looper.getMainLooper()) {
385
+ showSplashscreenNow();
386
+ } else {
387
+ this.mainHandler.post(this::showSplashscreenNow);
388
+ }
389
+ }
390
+
391
+ private void showSplashscreenNow() {
392
+ cancelSplashscreenTimeout();
393
+ this.autoSplashscreenTimedOut = false;
394
+
352
395
  try {
353
- // Show splashscreen immediately and synchronously when backgrounding
354
396
  if (getBridge() == null) {
355
397
  logger.warn("Bridge not ready for showing splashscreen with autoSplashscreen");
356
- return;
357
- }
358
-
359
- // Execute immediately on current thread if it's main, otherwise post to main thread
360
- if (android.os.Looper.myLooper() == android.os.Looper.getMainLooper()) {
361
- showSplashscreenNow();
362
398
  } else {
363
- // Use runOnUiThread for immediate execution on main thread
364
- if (getActivity() != null) {
365
- getActivity().runOnUiThread(() -> showSplashscreenNow());
399
+ PluginHandle splashScreenPlugin = getBridge().getPlugin("SplashScreen");
400
+ if (splashScreenPlugin != null) {
401
+ JSObject options = new JSObject();
402
+ java.lang.reflect.Field msgHandlerField = getBridge().getClass().getDeclaredField("msgHandler");
403
+ msgHandlerField.setAccessible(true);
404
+ Object msgHandler = msgHandlerField.get(getBridge());
405
+
406
+ PluginCall call = new PluginCall(
407
+ (com.getcapacitor.MessageHandler) msgHandler,
408
+ "SplashScreen",
409
+ "FAKE_CALLBACK_ID_SHOW",
410
+ "show",
411
+ options
412
+ );
413
+
414
+ splashScreenPlugin.invoke("show", call);
415
+ logger.info("Splashscreen shown synchronously to prevent flash");
366
416
  } else {
367
- new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> showSplashscreenNow());
417
+ logger.warn("autoSplashscreen: SplashScreen plugin not found");
368
418
  }
369
419
  }
370
420
  } catch (Exception e) {
371
- logger.error("Error showing splashscreen when backgrounding: " + e.getMessage());
421
+ logger.error("Failed to show splashscreen synchronously: " + e.getMessage());
372
422
  }
423
+
424
+ addSplashscreenLoaderIfNeeded();
425
+ scheduleSplashscreenTimeout();
373
426
  }
374
427
 
375
- private void showSplashscreenNow() {
376
- try {
377
- PluginHandle splashScreenPlugin = getBridge().getPlugin("SplashScreen");
378
- if (splashScreenPlugin != null) {
379
- JSObject options = new JSObject();
380
- java.lang.reflect.Field msgHandlerField = getBridge().getClass().getDeclaredField("msgHandler");
381
- msgHandlerField.setAccessible(true);
382
- Object msgHandler = msgHandlerField.get(getBridge());
383
-
384
- PluginCall call = new PluginCall(
385
- (com.getcapacitor.MessageHandler) msgHandler,
386
- "SplashScreen",
387
- "FAKE_CALLBACK_ID_SHOW",
388
- "show",
389
- options
390
- );
428
+ private void addSplashscreenLoaderIfNeeded() {
429
+ if (!Boolean.TRUE.equals(this.autoSplashscreenLoader)) {
430
+ return;
431
+ }
391
432
 
392
- splashScreenPlugin.invoke("show", call);
393
- logger.info("Splashscreen shown synchronously to prevent flash");
394
- } else {
395
- logger.warn("autoSplashscreen: SplashScreen plugin not found");
433
+ Runnable addLoader = () -> {
434
+ if (this.splashscreenLoaderOverlay != null) {
435
+ return;
396
436
  }
397
- } catch (Exception e) {
398
- logger.error("Failed to show splashscreen synchronously: " + e.getMessage());
437
+
438
+ Activity activity = getActivity();
439
+ if (activity == null) {
440
+ logger.warn("autoSplashscreen: Activity not available for loader overlay");
441
+ return;
442
+ }
443
+
444
+ ProgressBar progressBar = new ProgressBar(activity);
445
+ progressBar.setIndeterminate(true);
446
+
447
+ FrameLayout overlay = new FrameLayout(activity);
448
+ overlay.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
449
+ overlay.setClickable(false);
450
+ overlay.setFocusable(false);
451
+ overlay.setBackgroundColor(Color.TRANSPARENT);
452
+ overlay.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
453
+
454
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
455
+ ViewGroup.LayoutParams.WRAP_CONTENT,
456
+ ViewGroup.LayoutParams.WRAP_CONTENT
457
+ );
458
+ params.gravity = Gravity.CENTER;
459
+ overlay.addView(progressBar, params);
460
+
461
+ ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
462
+ decorView.addView(overlay);
463
+
464
+ this.splashscreenLoaderOverlay = overlay;
465
+ };
466
+
467
+ if (Looper.myLooper() == Looper.getMainLooper()) {
468
+ addLoader.run();
469
+ } else {
470
+ this.mainHandler.post(addLoader);
471
+ }
472
+ }
473
+
474
+ private void removeSplashscreenLoader() {
475
+ Runnable removeLoader = () -> {
476
+ if (this.splashscreenLoaderOverlay != null) {
477
+ ViewGroup parent = (ViewGroup) this.splashscreenLoaderOverlay.getParent();
478
+ if (parent != null) {
479
+ parent.removeView(this.splashscreenLoaderOverlay);
480
+ }
481
+ this.splashscreenLoaderOverlay = null;
482
+ }
483
+ };
484
+
485
+ if (Looper.myLooper() == Looper.getMainLooper()) {
486
+ removeLoader.run();
487
+ } else {
488
+ this.mainHandler.post(removeLoader);
489
+ }
490
+ }
491
+
492
+ private void scheduleSplashscreenTimeout() {
493
+ if (this.autoSplashscreenTimeout == null || this.autoSplashscreenTimeout <= 0) {
494
+ return;
495
+ }
496
+
497
+ cancelSplashscreenTimeout();
498
+
499
+ this.splashscreenTimeoutRunnable = () -> {
500
+ logger.info("autoSplashscreen timeout reached, hiding splashscreen");
501
+ this.autoSplashscreenTimedOut = true;
502
+ this.implementation.directUpdate = false;
503
+ hideSplashscreen();
504
+ };
505
+
506
+ this.mainHandler.postDelayed(this.splashscreenTimeoutRunnable, this.autoSplashscreenTimeout);
507
+ }
508
+
509
+ private void cancelSplashscreenTimeout() {
510
+ if (this.splashscreenTimeoutRunnable != null) {
511
+ this.mainHandler.removeCallbacks(this.splashscreenTimeoutRunnable);
512
+ this.splashscreenTimeoutRunnable = null;
399
513
  }
400
514
  }
401
515
 
@@ -415,6 +529,9 @@ public class CapacitorUpdaterPlugin extends Plugin {
415
529
  }
416
530
 
417
531
  private boolean shouldUseDirectUpdate() {
532
+ if (Boolean.TRUE.equals(this.autoSplashscreenTimedOut)) {
533
+ return false;
534
+ }
418
535
  switch (this.directUpdateMode) {
419
536
  case "false":
420
537
  return false;
@@ -432,6 +549,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
432
549
  }
433
550
  }
434
551
 
552
+ private boolean isDirectUpdateCurrentlyAllowed(final boolean plannedDirectUpdate) {
553
+ return plannedDirectUpdate && !Boolean.TRUE.equals(this.autoSplashscreenTimedOut);
554
+ }
555
+
435
556
  private void directUpdateFinish(final BundleInfo latest) {
436
557
  CapacitorUpdaterPlugin.this.implementation.set(latest);
437
558
  CapacitorUpdaterPlugin.this._reload();
@@ -1259,9 +1380,12 @@ public class CapacitorUpdaterPlugin extends Plugin {
1259
1380
  }
1260
1381
 
1261
1382
  private Thread backgroundDownload() {
1262
- boolean shouldDirectUpdate = this.shouldUseDirectUpdate();
1263
- this.implementation.directUpdate = shouldDirectUpdate;
1264
- String messageUpdate = shouldDirectUpdate ? "Update will occur now." : "Update will occur next time app moves to background.";
1383
+ final boolean plannedDirectUpdate = this.shouldUseDirectUpdate();
1384
+ final boolean initialDirectUpdateAllowed = this.isDirectUpdateCurrentlyAllowed(plannedDirectUpdate);
1385
+ this.implementation.directUpdate = initialDirectUpdateAllowed;
1386
+ final String messageUpdate = initialDirectUpdateAllowed
1387
+ ? "Update will occur now."
1388
+ : "Update will occur next time app moves to background.";
1265
1389
  return startNewThread(() -> {
1266
1390
  logger.info("Check for update via: " + CapacitorUpdaterPlugin.this.updateUrl);
1267
1391
  try {
@@ -1280,7 +1404,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1280
1404
  latestVersion,
1281
1405
  current,
1282
1406
  true,
1283
- shouldDirectUpdate
1407
+ plannedDirectUpdate
1284
1408
  );
1285
1409
  } else {
1286
1410
  CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
@@ -1288,7 +1412,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1288
1412
  latestVersion,
1289
1413
  current,
1290
1414
  true,
1291
- shouldDirectUpdate,
1415
+ plannedDirectUpdate,
1292
1416
  "backend_refusal",
1293
1417
  "backendRefused"
1294
1418
  );
@@ -1310,7 +1434,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1310
1434
  latestVersion,
1311
1435
  current,
1312
1436
  true,
1313
- shouldDirectUpdate,
1437
+ plannedDirectUpdate,
1314
1438
  "backend_refusal",
1315
1439
  "backendRefused"
1316
1440
  );
@@ -1321,7 +1445,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
1321
1445
 
1322
1446
  if ("builtin".equals(latestVersionName)) {
1323
1447
  logger.info("Latest version is builtin");
1324
- if (shouldDirectUpdate) {
1448
+ final boolean directUpdateAllowedNow = CapacitorUpdaterPlugin.this.isDirectUpdateCurrentlyAllowed(
1449
+ plannedDirectUpdate
1450
+ );
1451
+ if (directUpdateAllowedNow) {
1325
1452
  logger.info("Direct update to builtin version");
1326
1453
  this._reset(false);
1327
1454
  CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
@@ -1332,6 +1459,11 @@ public class CapacitorUpdaterPlugin extends Plugin {
1332
1459
  true
1333
1460
  );
1334
1461
  } else {
1462
+ if (plannedDirectUpdate && !directUpdateAllowedNow) {
1463
+ logger.info(
1464
+ "Direct update skipped because splashscreen timeout occurred. Update will be applied later."
1465
+ );
1466
+ }
1335
1467
  logger.info("Setting next bundle to builtin");
1336
1468
  CapacitorUpdaterPlugin.this.implementation.setNextBundle(BundleInfo.ID_BUILTIN);
1337
1469
  CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
@@ -1351,7 +1483,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1351
1483
  current.getVersionName(),
1352
1484
  current,
1353
1485
  true,
1354
- shouldDirectUpdate
1486
+ plannedDirectUpdate
1355
1487
  );
1356
1488
  return;
1357
1489
  }
@@ -1370,13 +1502,16 @@ public class CapacitorUpdaterPlugin extends Plugin {
1370
1502
  latestVersionName,
1371
1503
  current,
1372
1504
  true,
1373
- shouldDirectUpdate
1505
+ plannedDirectUpdate
1374
1506
  );
1375
1507
  return;
1376
1508
  }
1377
1509
  if (latest.isDownloaded()) {
1378
1510
  logger.info("Latest bundle already exists and download is NOT required. " + messageUpdate);
1379
- if (shouldDirectUpdate) {
1511
+ final boolean directUpdateAllowedNow = CapacitorUpdaterPlugin.this.isDirectUpdateCurrentlyAllowed(
1512
+ plannedDirectUpdate
1513
+ );
1514
+ if (directUpdateAllowedNow) {
1380
1515
  String delayUpdatePreferences = prefs.getString(DelayUpdateUtils.DELAY_CONDITION_PREFERENCES, "[]");
1381
1516
  ArrayList<DelayCondition> delayConditionList = delayUpdateUtils.parseDelayConditions(
1382
1517
  delayUpdatePreferences
@@ -1388,7 +1523,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1388
1523
  latestVersionName,
1389
1524
  latest,
1390
1525
  false,
1391
- shouldDirectUpdate
1526
+ plannedDirectUpdate
1392
1527
  );
1393
1528
  return;
1394
1529
  }
@@ -1402,6 +1537,11 @@ public class CapacitorUpdaterPlugin extends Plugin {
1402
1537
  true
1403
1538
  );
1404
1539
  } else {
1540
+ if (plannedDirectUpdate && !directUpdateAllowedNow) {
1541
+ logger.info(
1542
+ "Direct update skipped because splashscreen timeout occurred. Update will install on next background."
1543
+ );
1544
+ }
1405
1545
  CapacitorUpdaterPlugin.this.notifyListeners("updateAvailable", ret);
1406
1546
  CapacitorUpdaterPlugin.this.implementation.setNextBundle(latest.getId());
1407
1547
  CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
@@ -1467,7 +1607,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1467
1607
  latestVersionName,
1468
1608
  CapacitorUpdaterPlugin.this.implementation.getCurrentBundle(),
1469
1609
  true,
1470
- shouldDirectUpdate
1610
+ plannedDirectUpdate
1471
1611
  );
1472
1612
  }
1473
1613
  });
@@ -1482,7 +1622,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1482
1622
  current.getVersionName(),
1483
1623
  current,
1484
1624
  true,
1485
- shouldDirectUpdate
1625
+ plannedDirectUpdate
1486
1626
  );
1487
1627
  }
1488
1628
  });
@@ -1494,7 +1634,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1494
1634
  current.getVersionName(),
1495
1635
  current,
1496
1636
  true,
1497
- shouldDirectUpdate
1637
+ plannedDirectUpdate
1498
1638
  );
1499
1639
  }
1500
1640
  });
@@ -665,7 +665,7 @@ public class DownloadService extends Worker {
665
665
 
666
666
  // Verify checksum if provided
667
667
  if (expectedChecksum != null && !expectedChecksum.isEmpty()) {
668
- String actualChecksum = calculateFileChecksum(tempFile);
668
+ String actualChecksum = CryptoCipher.calcChecksum(tempFile);
669
669
  if (!expectedChecksum.equalsIgnoreCase(actualChecksum)) {
670
670
  tempFile.delete();
671
671
  throw new IOException("Checksum verification failed");
@@ -683,28 +683,6 @@ public class DownloadService extends Worker {
683
683
  }
684
684
  }
685
685
 
686
- /**
687
- * Calculate MD5 checksum of a file
688
- */
689
- private String calculateFileChecksum(File file) throws IOException {
690
- try (FileInputStream fis = new FileInputStream(file)) {
691
- MessageDigest md = MessageDigest.getInstance("MD5");
692
- byte[] buffer = new byte[8192];
693
- int bytesRead;
694
- while ((bytesRead = fis.read(buffer)) != -1) {
695
- md.update(buffer, 0, bytesRead);
696
- }
697
- byte[] digest = md.digest();
698
- StringBuilder sb = new StringBuilder();
699
- for (byte b : digest) {
700
- sb.append(String.format("%02x", b));
701
- }
702
- return sb.toString();
703
- } catch (Exception e) {
704
- throw new IOException("Failed to calculate checksum: " + e.getMessage(), e);
705
- }
706
- }
707
-
708
686
  /**
709
687
  * Clean up old temporary files
710
688
  */
package/dist/docs.json CHANGED
@@ -2451,6 +2451,38 @@
2451
2451
  "complexTypes": [],
2452
2452
  "type": "boolean | undefined"
2453
2453
  },
2454
+ {
2455
+ "name": "autoSplashscreenLoader",
2456
+ "tags": [
2457
+ {
2458
+ "text": "false",
2459
+ "name": "default"
2460
+ },
2461
+ {
2462
+ "text": "7.19.0",
2463
+ "name": "since"
2464
+ }
2465
+ ],
2466
+ "docs": "Display a native loading indicator on top of the splashscreen while automatic direct updates are running.\nOnly takes effect when {@link autoSplashscreen} is enabled.\nRequires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n\nOnly available for Android and iOS.",
2467
+ "complexTypes": [],
2468
+ "type": "boolean | undefined"
2469
+ },
2470
+ {
2471
+ "name": "autoSplashscreenTimeout",
2472
+ "tags": [
2473
+ {
2474
+ "text": "10000 // (10 seconds)",
2475
+ "name": "default"
2476
+ },
2477
+ {
2478
+ "text": "7.19.0",
2479
+ "name": "since"
2480
+ }
2481
+ ],
2482
+ "docs": "Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.\nIf the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.\nSet to `0` (zero) to disable the timeout.\nWhen the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.\nRequires {@link autoSplashscreen} to be enabled.\n\nOnly available for Android and iOS.",
2483
+ "complexTypes": [],
2484
+ "type": "number | undefined"
2485
+ },
2454
2486
  {
2455
2487
  "name": "periodCheckDelay",
2456
2488
  "tags": [
@@ -133,6 +133,30 @@ declare module '@capacitor/cli' {
133
133
  * @since 7.6.0
134
134
  */
135
135
  autoSplashscreen?: boolean;
136
+ /**
137
+ * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.
138
+ * Only takes effect when {@link autoSplashscreen} is enabled.
139
+ * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
140
+ *
141
+ * Only available for Android and iOS.
142
+ *
143
+ * @default false
144
+ * @since 7.19.0
145
+ */
146
+ autoSplashscreenLoader?: boolean;
147
+ /**
148
+ * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.
149
+ * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.
150
+ * Set to `0` (zero) to disable the timeout.
151
+ * When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.
152
+ * Requires {@link autoSplashscreen} to be enabled.
153
+ *
154
+ * Only available for Android and iOS.
155
+ *
156
+ * @default 10000 // (10 seconds)
157
+ * @since 7.19.0
158
+ */
159
+ autoSplashscreenTimeout?: number;
136
160
  /**
137
161
  * Configure the delay period for period update check. the unit is in seconds.
138
162
  *
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n\n/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * CapacitorUpdater can be configured with these options:\n */\n CapacitorUpdater?: {\n /**\n * Configure the number of milliseconds the native plugin should wait before considering an update 'failed'.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @example 1000 // (1 second)\n */\n appReadyTimeout?: number;\n /**\n * Configure the number of seconds the native plugin should wait before considering API timeout.\n *\n * Only available for Android and iOS.\n *\n * @default 20 // (20 second)\n * @example 10 // (10 second)\n */\n responseTimeout?: number;\n /**\n * Configure whether the plugin should use automatically delete failed bundles.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeleteFailed?: boolean;\n\n /**\n * Configure whether the plugin should use automatically delete previous bundles after a successful update.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeletePrevious?: boolean;\n\n /**\n * Configure whether the plugin should use Auto Update via an update server.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoUpdate?: boolean;\n\n /**\n * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n resetWhenUpdate?: boolean;\n\n /**\n * Configure the URL / endpoint to which update checks are sent.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/updates\n * @example https://example.com/api/auto_update\n */\n updateUrl?: string;\n\n /**\n * Configure the URL / endpoint for channel operations.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/channel_self\n * @example https://example.com/api/channel\n */\n channelUrl?: string;\n\n /**\n * Configure the URL / endpoint to which update statistics are sent.\n *\n * Only available for Android and iOS. Set to \"\" to disable stats reporting.\n *\n * @default https://plugin.capgo.app/stats\n * @example https://example.com/api/stats\n */\n statsUrl?: string;\n /**\n * Configure the public key for end to end live update encryption Version 2\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 6.2.0\n */\n publicKey?: string;\n\n /**\n * Configure the current version of the app. This will be used for the first update request.\n * If not set, the plugin will get the version from the native code.\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 4.17.48\n */\n version?: string;\n /**\n * Configure when the plugin should direct install updates. Only for autoUpdate mode.\n * Works well for apps less than 10MB and with uploads done using --partial flag.\n * Zip or apps more than 10MB will be relatively slow for users to update.\n * - false: Never do direct updates (default behavior)\n * - atInstall: Direct update only when app is installed/updated from store, otherwise use normal background update\n * - always: Always do direct updates immediately when available\n * - true: (deprecated) Same as \"always\" for backward compatibility\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 5.1.0\n */\n directUpdate?: boolean | 'atInstall' | 'always';\n\n /**\n * Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.\n * This removes the need to manually listen for appReady events and call SplashScreen.hide().\n * Only works when directUpdate is set to \"atInstall\", \"always\", or true.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n * Requires autoUpdate and directUpdate to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.6.0\n */\n autoSplashscreen?: boolean;\n\n /**\n * Configure the delay period for period update check. the unit is in seconds.\n *\n * Only available for Android and iOS.\n * Cannot be less than 600 seconds (10 minutes).\n *\n * @default 0 (disabled)\n * @example 3600 (1 hour)\n * @example 86400 (24 hours)\n */\n periodCheckDelay?: number;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localS3?: boolean;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localHost?: string;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localWebHost?: string;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupa?: string;\n /**\n * Configure the CLI to use a local server for testing.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupaAnon?: string;\n /**\n * Configure the CLI to use a local api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApi?: string;\n /**\n * Configure the CLI to use a local file api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApiFiles?: string;\n /**\n * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 5.4.0\n */\n allowModifyUrl?: boolean;\n\n /**\n * Allow the plugin to modify the appId dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 7.14.0\n */\n allowModifyAppId?: boolean;\n\n /**\n * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false (will be true by default in a future major release v8.x.x)\n * @since 7.17.3\n */\n persistCustomId?: boolean;\n\n /**\n * Set the default channel for the app in the config. Case sensitive.\n * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.\n * This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options\n *\n *\n * @default undefined\n * @since 5.5.0\n */\n defaultChannel?: string;\n /**\n * Configure the app id for the app in the config.\n *\n * @default undefined\n * @since 6.0.0\n */\n appId?: string;\n\n /**\n * Configure the plugin to keep the URL path after a reload.\n * WARNING: When a reload is triggered, 'window.history' will be cleared.\n *\n * @default false\n * @since 6.8.0\n */\n keepUrlPathAfterReload?: boolean;\n /**\n * Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done\n *\n * @default false\n * @since 7.3.0\n */\n disableJSLogging?: boolean;\n /**\n * Enable shake gesture to show update menu for debugging/testing purposes\n *\n * @default false\n * @since 7.5.0\n */\n shakeMenu?: boolean;\n };\n }\n}\n\nexport interface CapacitorUpdaterPlugin {\n /**\n * Notify Capacitor Updater that the current bundle is working (a rollback will occur if this method is not called on every app launch)\n * By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur.\n * Change this behaviour with {@link appReadyTimeout}\n *\n * @returns {Promise<AppReadyResult>} an Promise resolved directly\n * @throws {Error}\n */\n notifyAppReady(): Promise<AppReadyResult>;\n\n /**\n * Set the updateUrl for the app, this will be used to check for updates.\n *\n * @param options contains the URL to use for checking for updates.\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 5.4.0\n */\n setUpdateUrl(options: UpdateUrl): Promise<void>;\n\n /**\n * Set the statsUrl for the app, this will be used to send statistics. Passing an empty string will disable statistics gathering.\n *\n * @param options contains the URL to use for sending statistics.\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 5.4.0\n */\n setStatsUrl(options: StatsUrl): Promise<void>;\n\n /**\n * Set the channelUrl for the app, this will be used to set the channel.\n *\n * @param options contains the URL to use for setting the channel.\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 5.4.0\n */\n setChannelUrl(options: ChannelUrl): Promise<void>;\n\n /**\n * Download a new bundle from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files\n *\n * @example const bundle = await CapacitorUpdater.download({ url: `https://example.com/versions/${version}/dist.zip`, version });\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.\n * @param options The {@link DownloadOptions} for downloading a new bundle zip.\n */\n download(options: DownloadOptions): Promise<BundleInfo>;\n\n /**\n * Set the next bundle to be used when the app is reloaded.\n *\n * @param options Contains the ID of the next Bundle to set on next app launch. {@link BundleInfo.id}\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle id.\n * @throws {Error} When there is no index.html file inside the bundle folder.\n */\n next(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Set the current bundle and immediately reloads the app.\n *\n * @param options A {@link BundleId} object containing the new bundle id to set as current.\n * @returns {Promise<void>}\n * @throws {Error} When there are is no index.html file inside the bundle folder.\n */\n set(options: BundleId): Promise<void>;\n\n /**\n * Deletes the specified bundle from the native app storage. Use with {@link list} to get the stored Bundle IDs.\n *\n * @param options A {@link BundleId} object containing the ID of a bundle to delete (note, this is the bundle id, NOT the version name)\n * @returns {Promise<void>} When the bundle is deleted\n * @throws {Error}\n */\n delete(options: BundleId): Promise<void>;\n\n /**\n * Get all locally downloaded bundles in your app\n *\n * @returns {Promise<BundleListResult>} A Promise containing the {@link BundleListResult.bundles}\n * @param options The {@link ListOptions} for listing bundles\n * @throws {Error}\n */\n list(options?: ListOptions): Promise<BundleListResult>;\n\n /**\n * Reset the app to the `builtin` bundle (the one sent to Apple App Store / Google Play Store ) or the last successfully loaded bundle.\n *\n * @param options Containing {@link ResetOptions.toLastSuccessful}, `true` resets to the builtin bundle and `false` will reset to the last successfully loaded bundle.\n * @returns {Promise<void>}\n * @throws {Error}\n */\n reset(options?: ResetOptions): Promise<void>;\n\n /**\n * Get the current bundle, if none are set it returns `builtin`. currentNative is the original bundle installed on the device\n *\n * @returns {Promise<CurrentBundleResult>} A Promise evaluating to the {@link CurrentBundleResult}\n * @throws {Error}\n */\n current(): Promise<CurrentBundleResult>;\n\n /**\n * Reload the view\n *\n * @returns {Promise<void>} A Promise which is resolved when the view is reloaded\n * @throws {Error}\n */\n reload(): Promise<void>;\n\n /**\n * Sets a {@link DelayCondition} array containing conditions that the Plugin will use to delay the update.\n * After all conditions are met, the update process will run start again as usual, so update will be installed after a backgrounding or killing the app.\n * For the `date` kind, the value should be an iso8601 date string.\n * For the `background` kind, the value should be a number in milliseconds.\n * For the `nativeVersion` kind, the value should be the version number.\n * For the `kill` kind, the value is not used.\n * The function has unconsistent behavior the option kill do trigger the update after the first kill and not after the next background like other options. This will be fixed in a future major release.\n *\n * @example\n * // Delay the update after the user kills the app or after a background of 300000 ms (5 minutes)\n * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'kill' }, { kind: 'background', value: '300000' }] })\n * @example\n * // Delay the update after the specific iso8601 date is expired\n * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'date', value: '2022-09-14T06:14:11.920Z' }] })\n * @example\n * // Delay the update after the first background (default behaviour without setting delay)\n * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'background' }] })\n * @param options Containing the {@link MultiDelayConditions} array of conditions to set\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 4.3.0\n */\n setMultiDelay(options: MultiDelayConditions): Promise<void>;\n\n /**\n * Cancels a {@link DelayCondition} to process an update immediately.\n *\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 4.0.0\n */\n cancelDelay(): Promise<void>;\n\n /**\n * Get Latest bundle available from update Url\n *\n * @returns {Promise<LatestVersion>} A Promise resolved when url is loaded\n * @throws {Error}\n * @since 4.0.0\n */\n getLatest(options?: GetLatestOptions): Promise<LatestVersion>;\n\n /**\n * Sets the channel for this device. The channel has to allow for self assignment for this to work.\n * Do not use this method to set the channel at boot.\n * This method is to set the channel after the app is ready, and user interacted.\n * If you want to set the channel at boot, use the {@link PluginsConfig} to set the default channel.\n * This methods send to Capgo backend a request to link the device ID to the channel. Capgo can accept or refuse depending of the setting of your channel.\n *\n *\n *\n * @param options Is the {@link SetChannelOptions} channel to set\n * @returns {Promise<ChannelRes>} A Promise which is resolved when the new channel is set\n * @throws {Error}\n * @since 4.7.0\n */\n setChannel(options: SetChannelOptions): Promise<ChannelRes>;\n\n /**\n * Unset the channel for this device. The device will then return to the default channel\n *\n * @returns {Promise<ChannelRes>} A Promise resolved when channel is set\n * @throws {Error}\n * @since 4.7.0\n */\n unsetChannel(options: UnsetChannelOptions): Promise<void>;\n\n /**\n * Get the channel for this device\n *\n * @returns {Promise<ChannelRes>} A Promise that resolves with the channel info\n * @throws {Error}\n * @since 4.8.0\n */\n getChannel(): Promise<GetChannelRes>;\n\n /**\n * List all channels available for this device that allow self-assignment\n *\n * @returns {Promise<ListChannelsResult>} A Promise that resolves with the available channels\n * @throws {Error}\n * @since 7.5.0\n */\n listChannels(): Promise<ListChannelsResult>;\n\n /**\n * Set a custom ID for this device\n *\n * When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is true, the value will be stored natively and restored on the next app launch.\n * Pass an empty string to remove any previously stored customId.\n *\n * @param options is the {@link SetCustomIdOptions} customId to set\n * @returns {Promise<void>} an Promise resolved instantly\n * @throws {Error}\n * @since 4.9.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n\n /**\n * Get the native app version or the builtin version if set in config\n *\n * @returns {Promise<BuiltinVersion>} A Promise with version for this device\n * @since 5.2.0\n */\n getBuiltinVersion(): Promise<BuiltinVersion>;\n\n /**\n * Get unique ID used to identify device (sent to auto update server)\n *\n * @returns {Promise<DeviceId>} A Promise with id for this device\n * @throws {Error}\n */\n getDeviceId(): Promise<DeviceId>;\n\n /**\n * Get the native Capacitor Updater plugin version (sent to auto update server)\n *\n * @returns {Promise<PluginVersion>} A Promise with Plugin version\n * @throws {Error}\n */\n getPluginVersion(): Promise<PluginVersion>;\n\n /**\n * Get the state of auto update config.\n *\n * @returns {Promise<AutoUpdateEnabled>} The status for auto update. Evaluates to `false` in manual mode.\n * @throws {Error}\n */\n isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.\n * This will return you all download percent during the download\n *\n * @since 2.0.11\n */\n addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for no need to update event, useful when you want force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for available update event, useful when you want to force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'updateAvailable',\n listenerFunc: (state: UpdateAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for downloadComplete events.\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadComplete',\n listenerFunc: (state: DownloadCompleteEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking\n *\n * @since 2.3.0\n */\n addListener(\n eventName: 'majorAvailable',\n listenerFunc: (state: MajorAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for update fail event in the App, let you know when update has fail to install at next app start\n *\n * @since 2.3.0\n */\n addListener(\n eventName: 'updateFailed',\n listenerFunc: (state: UpdateFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for download fail event in the App, let you know when a bundle download has failed\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadFailed',\n listenerFunc: (state: DownloadFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for reload event in the App, let you know when reload has happened\n *\n * @since 4.3.0\n */\n addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for app ready event in the App, let you know when app is ready to use, this event is retain till consumed.\n *\n * @since 5.1.0\n */\n addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Get if auto update is available (not disabled by serverUrl).\n *\n * @returns {Promise<AutoUpdateAvailable>} The availability status for auto update. Evaluates to `false` when serverUrl is set.\n * @throws {Error}\n */\n isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;\n\n /**\n * Get the next bundle that will be used when the app reloads.\n * Returns null if no next bundle is set.\n *\n * @returns {Promise<BundleInfo | null>} A Promise that resolves with the next bundle information or null\n * @throws {Error}\n * @since 6.8.0\n */\n getNextBundle(): Promise<BundleInfo | null>;\n\n /**\n * Enable or disable the shake menu for debugging/testing purposes\n *\n * @param options Contains enabled boolean to enable or disable shake menu\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 7.5.0\n */\n setShakeMenu(options: SetShakeMenuOptions): Promise<void>;\n\n /**\n * Get the current state of the shake menu\n *\n * @returns {Promise<ShakeMenuEnabled>} The current state of shake menu\n * @throws {Error}\n * @since 7.5.0\n */\n isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;\n\n /**\n * Get the configured App ID\n *\n * @returns {Promise<GetAppIdRes>} The current App ID\n * @throws {Error}\n * @since 7.14.0\n */\n getAppId(): Promise<GetAppIdRes>;\n\n /**\n * Set the App ID for the app (requires allowModifyAppId to be true in config)\n *\n * @param options The new App ID to set\n * @returns {Promise<void>}\n * @throws {Error} If allowModifyAppId is false or if the operation fails\n * @since 7.14.0\n */\n setAppId(options: SetAppIdOptions): Promise<void>;\n}\n\n/**\n * pending: The bundle is pending to be **SET** as the next bundle.\n * downloading: The bundle is being downloaded.\n * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.\n * error: The bundle has failed to download.\n */\nexport type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';\n\nexport type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';\n\nexport interface NoNeedEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateAvailableEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface ChannelRes {\n /**\n * Current status of set channel\n *\n * @since 4.7.0\n */\n status: string;\n error?: string;\n message?: string;\n}\n\nexport interface GetChannelRes {\n /**\n * Current status of get channel\n *\n * @since 4.8.0\n */\n channel?: string;\n error?: string;\n message?: string;\n status?: string;\n allowSet?: boolean;\n}\n\nexport interface ChannelInfo {\n /**\n * The channel ID\n *\n * @since 7.5.0\n */\n id: string;\n /**\n * The channel name\n *\n * @since 7.5.0\n */\n name: string;\n /**\n * Whether this is a public channel\n *\n * @since 7.5.0\n */\n public: boolean;\n /**\n * Whether devices can self-assign to this channel\n *\n * @since 7.5.0\n */\n allow_self_set: boolean;\n}\n\nexport interface ListChannelsResult {\n /**\n * List of available channels\n *\n * @since 7.5.0\n */\n channels: ChannelInfo[];\n}\n\nexport interface DownloadEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n percent: number;\n bundle: BundleInfo;\n}\n\nexport interface MajorAvailableEvent {\n /**\n * Emit when a new major bundle is available.\n *\n * @since 4.0.0\n */\n version: string;\n}\n\nexport interface DownloadFailedEvent {\n /**\n * Emit when a download fail.\n *\n * @since 4.0.0\n */\n version: string;\n}\n\nexport interface DownloadCompleteEvent {\n /**\n * Emit when a new update is available.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateFailedEvent {\n /**\n * Emit when a update failed to install.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface AppReadyEvent {\n /**\n * Emitted when the app is ready to use.\n *\n * @since 5.2.0\n */\n bundle: BundleInfo;\n status: string;\n}\n\nexport interface ManifestEntry {\n file_name: string | null;\n file_hash: string | null;\n download_url: string | null;\n}\n\nexport interface LatestVersion {\n /**\n * Result of getLatest method\n *\n * @since 4.0.0\n */\n version: string;\n /**\n * @since 6\n */\n checksum?: string;\n major?: boolean;\n message?: string;\n sessionKey?: string;\n error?: string;\n old?: string;\n url?: string;\n /**\n * @since 6.1\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleInfo {\n id: string;\n version: string;\n downloaded: string;\n checksum: string;\n status: BundleStatus;\n}\n\nexport interface SetChannelOptions {\n channel: string;\n triggerAutoUpdate?: boolean;\n}\n\nexport interface UnsetChannelOptions {\n triggerAutoUpdate?: boolean;\n}\n\nexport interface SetCustomIdOptions {\n /**\n * Custom identifier to associate with the device. Use an empty string to clear any saved value.\n */\n customId: string;\n}\n\nexport interface DelayCondition {\n /**\n * Set up delay conditions in setMultiDelay\n * @param value is useless for @param kind \"kill\", optional for \"background\" (default value: \"0\") and required for \"nativeVersion\" and \"date\"\n */\n kind: DelayUntilNext;\n value?: string;\n}\n\nexport interface GetLatestOptions {\n /**\n * The channel to get the latest version for\n * The channel must allow 'self_assign' for this to work\n * @since 6.8.0\n * @default undefined\n */\n channel?: string;\n}\n\nexport interface AppReadyResult {\n bundle: BundleInfo;\n}\n\nexport interface UpdateUrl {\n url: string;\n}\n\nexport interface StatsUrl {\n url: string;\n}\n\nexport interface ChannelUrl {\n url: string;\n}\n\n/**\n * This URL and versions are used to download the bundle from the server, If you use backend all information will be gived by the method getLatest.\n * If you don't use backend, you need to provide the URL and version of the bundle. Checksum and sessionKey are required if you encrypted the bundle with the CLI command encrypt, you should receive them as result of the command.\n */\nexport interface DownloadOptions {\n /**\n * The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.)\n */\n url: string;\n /**\n * The version code/name of this bundle/version\n */\n version: string;\n /**\n * The session key for the update, when the bundle is encrypted with a session key\n * @since 4.0.0\n * @default undefined\n */\n sessionKey?: string;\n /**\n * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted\n * @since 4.0.0\n * @default undefined\n */\n checksum?: string;\n /**\n * The manifest for multi-file downloads\n * @since 6.1.0\n * @default undefined\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleId {\n id: string;\n}\n\nexport interface BundleListResult {\n bundles: BundleInfo[];\n}\n\nexport interface ResetOptions {\n toLastSuccessful: boolean;\n}\n\nexport interface ListOptions {\n /**\n * Whether to return the raw bundle list or the manifest. If true, the list will attempt to read the internal database instead of files on disk.\n * @since 6.14.0\n * @default false\n */\n raw?: boolean;\n}\n\nexport interface CurrentBundleResult {\n bundle: BundleInfo;\n native: string;\n}\n\nexport interface MultiDelayConditions {\n delayConditions: DelayCondition[];\n}\n\nexport interface BuiltinVersion {\n version: string;\n}\n\nexport interface DeviceId {\n deviceId: string;\n}\n\nexport interface PluginVersion {\n version: string;\n}\n\nexport interface AutoUpdateEnabled {\n enabled: boolean;\n}\n\nexport interface AutoUpdateAvailable {\n available: boolean;\n}\n\nexport interface SetShakeMenuOptions {\n enabled: boolean;\n}\n\nexport interface ShakeMenuEnabled {\n enabled: boolean;\n}\n\nexport interface GetAppIdRes {\n appId: string;\n}\n\nexport interface SetAppIdOptions {\n appId: string;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n\n/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * CapacitorUpdater can be configured with these options:\n */\n CapacitorUpdater?: {\n /**\n * Configure the number of milliseconds the native plugin should wait before considering an update 'failed'.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @example 1000 // (1 second)\n */\n appReadyTimeout?: number;\n /**\n * Configure the number of seconds the native plugin should wait before considering API timeout.\n *\n * Only available for Android and iOS.\n *\n * @default 20 // (20 second)\n * @example 10 // (10 second)\n */\n responseTimeout?: number;\n /**\n * Configure whether the plugin should use automatically delete failed bundles.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeleteFailed?: boolean;\n\n /**\n * Configure whether the plugin should use automatically delete previous bundles after a successful update.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeletePrevious?: boolean;\n\n /**\n * Configure whether the plugin should use Auto Update via an update server.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoUpdate?: boolean;\n\n /**\n * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n resetWhenUpdate?: boolean;\n\n /**\n * Configure the URL / endpoint to which update checks are sent.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/updates\n * @example https://example.com/api/auto_update\n */\n updateUrl?: string;\n\n /**\n * Configure the URL / endpoint for channel operations.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/channel_self\n * @example https://example.com/api/channel\n */\n channelUrl?: string;\n\n /**\n * Configure the URL / endpoint to which update statistics are sent.\n *\n * Only available for Android and iOS. Set to \"\" to disable stats reporting.\n *\n * @default https://plugin.capgo.app/stats\n * @example https://example.com/api/stats\n */\n statsUrl?: string;\n /**\n * Configure the public key for end to end live update encryption Version 2\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 6.2.0\n */\n publicKey?: string;\n\n /**\n * Configure the current version of the app. This will be used for the first update request.\n * If not set, the plugin will get the version from the native code.\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 4.17.48\n */\n version?: string;\n /**\n * Configure when the plugin should direct install updates. Only for autoUpdate mode.\n * Works well for apps less than 10MB and with uploads done using --partial flag.\n * Zip or apps more than 10MB will be relatively slow for users to update.\n * - false: Never do direct updates (default behavior)\n * - atInstall: Direct update only when app is installed/updated from store, otherwise use normal background update\n * - always: Always do direct updates immediately when available\n * - true: (deprecated) Same as \"always\" for backward compatibility\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 5.1.0\n */\n directUpdate?: boolean | 'atInstall' | 'always';\n\n /**\n * Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.\n * This removes the need to manually listen for appReady events and call SplashScreen.hide().\n * Only works when directUpdate is set to \"atInstall\", \"always\", or true.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n * Requires autoUpdate and directUpdate to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.6.0\n */\n autoSplashscreen?: boolean;\n\n /**\n * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.\n * Only takes effect when {@link autoSplashscreen} is enabled.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.19.0\n */\n autoSplashscreenLoader?: boolean;\n\n /**\n * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.\n * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.\n * Set to `0` (zero) to disable the timeout.\n * When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.\n * Requires {@link autoSplashscreen} to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @since 7.19.0\n */\n autoSplashscreenTimeout?: number;\n\n /**\n * Configure the delay period for period update check. the unit is in seconds.\n *\n * Only available for Android and iOS.\n * Cannot be less than 600 seconds (10 minutes).\n *\n * @default 0 (disabled)\n * @example 3600 (1 hour)\n * @example 86400 (24 hours)\n */\n periodCheckDelay?: number;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localS3?: boolean;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localHost?: string;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localWebHost?: string;\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupa?: string;\n /**\n * Configure the CLI to use a local server for testing.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupaAnon?: string;\n /**\n * Configure the CLI to use a local api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApi?: string;\n /**\n * Configure the CLI to use a local file api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApiFiles?: string;\n /**\n * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 5.4.0\n */\n allowModifyUrl?: boolean;\n\n /**\n * Allow the plugin to modify the appId dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 7.14.0\n */\n allowModifyAppId?: boolean;\n\n /**\n * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false (will be true by default in a future major release v8.x.x)\n * @since 7.17.3\n */\n persistCustomId?: boolean;\n\n /**\n * Set the default channel for the app in the config. Case sensitive.\n * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.\n * This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options\n *\n *\n * @default undefined\n * @since 5.5.0\n */\n defaultChannel?: string;\n /**\n * Configure the app id for the app in the config.\n *\n * @default undefined\n * @since 6.0.0\n */\n appId?: string;\n\n /**\n * Configure the plugin to keep the URL path after a reload.\n * WARNING: When a reload is triggered, 'window.history' will be cleared.\n *\n * @default false\n * @since 6.8.0\n */\n keepUrlPathAfterReload?: boolean;\n /**\n * Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done\n *\n * @default false\n * @since 7.3.0\n */\n disableJSLogging?: boolean;\n /**\n * Enable shake gesture to show update menu for debugging/testing purposes\n *\n * @default false\n * @since 7.5.0\n */\n shakeMenu?: boolean;\n };\n }\n}\n\nexport interface CapacitorUpdaterPlugin {\n /**\n * Notify Capacitor Updater that the current bundle is working (a rollback will occur if this method is not called on every app launch)\n * By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur.\n * Change this behaviour with {@link appReadyTimeout}\n *\n * @returns {Promise<AppReadyResult>} an Promise resolved directly\n * @throws {Error}\n */\n notifyAppReady(): Promise<AppReadyResult>;\n\n /**\n * Set the updateUrl for the app, this will be used to check for updates.\n *\n * @param options contains the URL to use for checking for updates.\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 5.4.0\n */\n setUpdateUrl(options: UpdateUrl): Promise<void>;\n\n /**\n * Set the statsUrl for the app, this will be used to send statistics. Passing an empty string will disable statistics gathering.\n *\n * @param options contains the URL to use for sending statistics.\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 5.4.0\n */\n setStatsUrl(options: StatsUrl): Promise<void>;\n\n /**\n * Set the channelUrl for the app, this will be used to set the channel.\n *\n * @param options contains the URL to use for setting the channel.\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 5.4.0\n */\n setChannelUrl(options: ChannelUrl): Promise<void>;\n\n /**\n * Download a new bundle from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files\n *\n * @example const bundle = await CapacitorUpdater.download({ url: `https://example.com/versions/${version}/dist.zip`, version });\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.\n * @param options The {@link DownloadOptions} for downloading a new bundle zip.\n */\n download(options: DownloadOptions): Promise<BundleInfo>;\n\n /**\n * Set the next bundle to be used when the app is reloaded.\n *\n * @param options Contains the ID of the next Bundle to set on next app launch. {@link BundleInfo.id}\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle id.\n * @throws {Error} When there is no index.html file inside the bundle folder.\n */\n next(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Set the current bundle and immediately reloads the app.\n *\n * @param options A {@link BundleId} object containing the new bundle id to set as current.\n * @returns {Promise<void>}\n * @throws {Error} When there are is no index.html file inside the bundle folder.\n */\n set(options: BundleId): Promise<void>;\n\n /**\n * Deletes the specified bundle from the native app storage. Use with {@link list} to get the stored Bundle IDs.\n *\n * @param options A {@link BundleId} object containing the ID of a bundle to delete (note, this is the bundle id, NOT the version name)\n * @returns {Promise<void>} When the bundle is deleted\n * @throws {Error}\n */\n delete(options: BundleId): Promise<void>;\n\n /**\n * Get all locally downloaded bundles in your app\n *\n * @returns {Promise<BundleListResult>} A Promise containing the {@link BundleListResult.bundles}\n * @param options The {@link ListOptions} for listing bundles\n * @throws {Error}\n */\n list(options?: ListOptions): Promise<BundleListResult>;\n\n /**\n * Reset the app to the `builtin` bundle (the one sent to Apple App Store / Google Play Store ) or the last successfully loaded bundle.\n *\n * @param options Containing {@link ResetOptions.toLastSuccessful}, `true` resets to the builtin bundle and `false` will reset to the last successfully loaded bundle.\n * @returns {Promise<void>}\n * @throws {Error}\n */\n reset(options?: ResetOptions): Promise<void>;\n\n /**\n * Get the current bundle, if none are set it returns `builtin`. currentNative is the original bundle installed on the device\n *\n * @returns {Promise<CurrentBundleResult>} A Promise evaluating to the {@link CurrentBundleResult}\n * @throws {Error}\n */\n current(): Promise<CurrentBundleResult>;\n\n /**\n * Reload the view\n *\n * @returns {Promise<void>} A Promise which is resolved when the view is reloaded\n * @throws {Error}\n */\n reload(): Promise<void>;\n\n /**\n * Sets a {@link DelayCondition} array containing conditions that the Plugin will use to delay the update.\n * After all conditions are met, the update process will run start again as usual, so update will be installed after a backgrounding or killing the app.\n * For the `date` kind, the value should be an iso8601 date string.\n * For the `background` kind, the value should be a number in milliseconds.\n * For the `nativeVersion` kind, the value should be the version number.\n * For the `kill` kind, the value is not used.\n * The function has unconsistent behavior the option kill do trigger the update after the first kill and not after the next background like other options. This will be fixed in a future major release.\n *\n * @example\n * // Delay the update after the user kills the app or after a background of 300000 ms (5 minutes)\n * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'kill' }, { kind: 'background', value: '300000' }] })\n * @example\n * // Delay the update after the specific iso8601 date is expired\n * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'date', value: '2022-09-14T06:14:11.920Z' }] })\n * @example\n * // Delay the update after the first background (default behaviour without setting delay)\n * await CapacitorUpdater.setMultiDelay({ delayConditions: [{ kind: 'background' }] })\n * @param options Containing the {@link MultiDelayConditions} array of conditions to set\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 4.3.0\n */\n setMultiDelay(options: MultiDelayConditions): Promise<void>;\n\n /**\n * Cancels a {@link DelayCondition} to process an update immediately.\n *\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 4.0.0\n */\n cancelDelay(): Promise<void>;\n\n /**\n * Get Latest bundle available from update Url\n *\n * @returns {Promise<LatestVersion>} A Promise resolved when url is loaded\n * @throws {Error}\n * @since 4.0.0\n */\n getLatest(options?: GetLatestOptions): Promise<LatestVersion>;\n\n /**\n * Sets the channel for this device. The channel has to allow for self assignment for this to work.\n * Do not use this method to set the channel at boot.\n * This method is to set the channel after the app is ready, and user interacted.\n * If you want to set the channel at boot, use the {@link PluginsConfig} to set the default channel.\n * This methods send to Capgo backend a request to link the device ID to the channel. Capgo can accept or refuse depending of the setting of your channel.\n *\n *\n *\n * @param options Is the {@link SetChannelOptions} channel to set\n * @returns {Promise<ChannelRes>} A Promise which is resolved when the new channel is set\n * @throws {Error}\n * @since 4.7.0\n */\n setChannel(options: SetChannelOptions): Promise<ChannelRes>;\n\n /**\n * Unset the channel for this device. The device will then return to the default channel\n *\n * @returns {Promise<ChannelRes>} A Promise resolved when channel is set\n * @throws {Error}\n * @since 4.7.0\n */\n unsetChannel(options: UnsetChannelOptions): Promise<void>;\n\n /**\n * Get the channel for this device\n *\n * @returns {Promise<ChannelRes>} A Promise that resolves with the channel info\n * @throws {Error}\n * @since 4.8.0\n */\n getChannel(): Promise<GetChannelRes>;\n\n /**\n * List all channels available for this device that allow self-assignment\n *\n * @returns {Promise<ListChannelsResult>} A Promise that resolves with the available channels\n * @throws {Error}\n * @since 7.5.0\n */\n listChannels(): Promise<ListChannelsResult>;\n\n /**\n * Set a custom ID for this device\n *\n * When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is true, the value will be stored natively and restored on the next app launch.\n * Pass an empty string to remove any previously stored customId.\n *\n * @param options is the {@link SetCustomIdOptions} customId to set\n * @returns {Promise<void>} an Promise resolved instantly\n * @throws {Error}\n * @since 4.9.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n\n /**\n * Get the native app version or the builtin version if set in config\n *\n * @returns {Promise<BuiltinVersion>} A Promise with version for this device\n * @since 5.2.0\n */\n getBuiltinVersion(): Promise<BuiltinVersion>;\n\n /**\n * Get unique ID used to identify device (sent to auto update server)\n *\n * @returns {Promise<DeviceId>} A Promise with id for this device\n * @throws {Error}\n */\n getDeviceId(): Promise<DeviceId>;\n\n /**\n * Get the native Capacitor Updater plugin version (sent to auto update server)\n *\n * @returns {Promise<PluginVersion>} A Promise with Plugin version\n * @throws {Error}\n */\n getPluginVersion(): Promise<PluginVersion>;\n\n /**\n * Get the state of auto update config.\n *\n * @returns {Promise<AutoUpdateEnabled>} The status for auto update. Evaluates to `false` in manual mode.\n * @throws {Error}\n */\n isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.\n * This will return you all download percent during the download\n *\n * @since 2.0.11\n */\n addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for no need to update event, useful when you want force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for available update event, useful when you want to force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'updateAvailable',\n listenerFunc: (state: UpdateAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for downloadComplete events.\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadComplete',\n listenerFunc: (state: DownloadCompleteEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking\n *\n * @since 2.3.0\n */\n addListener(\n eventName: 'majorAvailable',\n listenerFunc: (state: MajorAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for update fail event in the App, let you know when update has fail to install at next app start\n *\n * @since 2.3.0\n */\n addListener(\n eventName: 'updateFailed',\n listenerFunc: (state: UpdateFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for download fail event in the App, let you know when a bundle download has failed\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadFailed',\n listenerFunc: (state: DownloadFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for reload event in the App, let you know when reload has happened\n *\n * @since 4.3.0\n */\n addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for app ready event in the App, let you know when app is ready to use, this event is retain till consumed.\n *\n * @since 5.1.0\n */\n addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Get if auto update is available (not disabled by serverUrl).\n *\n * @returns {Promise<AutoUpdateAvailable>} The availability status for auto update. Evaluates to `false` when serverUrl is set.\n * @throws {Error}\n */\n isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;\n\n /**\n * Get the next bundle that will be used when the app reloads.\n * Returns null if no next bundle is set.\n *\n * @returns {Promise<BundleInfo | null>} A Promise that resolves with the next bundle information or null\n * @throws {Error}\n * @since 6.8.0\n */\n getNextBundle(): Promise<BundleInfo | null>;\n\n /**\n * Enable or disable the shake menu for debugging/testing purposes\n *\n * @param options Contains enabled boolean to enable or disable shake menu\n * @returns {Promise<void>}\n * @throws {Error}\n * @since 7.5.0\n */\n setShakeMenu(options: SetShakeMenuOptions): Promise<void>;\n\n /**\n * Get the current state of the shake menu\n *\n * @returns {Promise<ShakeMenuEnabled>} The current state of shake menu\n * @throws {Error}\n * @since 7.5.0\n */\n isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;\n\n /**\n * Get the configured App ID\n *\n * @returns {Promise<GetAppIdRes>} The current App ID\n * @throws {Error}\n * @since 7.14.0\n */\n getAppId(): Promise<GetAppIdRes>;\n\n /**\n * Set the App ID for the app (requires allowModifyAppId to be true in config)\n *\n * @param options The new App ID to set\n * @returns {Promise<void>}\n * @throws {Error} If allowModifyAppId is false or if the operation fails\n * @since 7.14.0\n */\n setAppId(options: SetAppIdOptions): Promise<void>;\n}\n\n/**\n * pending: The bundle is pending to be **SET** as the next bundle.\n * downloading: The bundle is being downloaded.\n * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.\n * error: The bundle has failed to download.\n */\nexport type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';\n\nexport type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';\n\nexport interface NoNeedEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateAvailableEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface ChannelRes {\n /**\n * Current status of set channel\n *\n * @since 4.7.0\n */\n status: string;\n error?: string;\n message?: string;\n}\n\nexport interface GetChannelRes {\n /**\n * Current status of get channel\n *\n * @since 4.8.0\n */\n channel?: string;\n error?: string;\n message?: string;\n status?: string;\n allowSet?: boolean;\n}\n\nexport interface ChannelInfo {\n /**\n * The channel ID\n *\n * @since 7.5.0\n */\n id: string;\n /**\n * The channel name\n *\n * @since 7.5.0\n */\n name: string;\n /**\n * Whether this is a public channel\n *\n * @since 7.5.0\n */\n public: boolean;\n /**\n * Whether devices can self-assign to this channel\n *\n * @since 7.5.0\n */\n allow_self_set: boolean;\n}\n\nexport interface ListChannelsResult {\n /**\n * List of available channels\n *\n * @since 7.5.0\n */\n channels: ChannelInfo[];\n}\n\nexport interface DownloadEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n percent: number;\n bundle: BundleInfo;\n}\n\nexport interface MajorAvailableEvent {\n /**\n * Emit when a new major bundle is available.\n *\n * @since 4.0.0\n */\n version: string;\n}\n\nexport interface DownloadFailedEvent {\n /**\n * Emit when a download fail.\n *\n * @since 4.0.0\n */\n version: string;\n}\n\nexport interface DownloadCompleteEvent {\n /**\n * Emit when a new update is available.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateFailedEvent {\n /**\n * Emit when a update failed to install.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface AppReadyEvent {\n /**\n * Emitted when the app is ready to use.\n *\n * @since 5.2.0\n */\n bundle: BundleInfo;\n status: string;\n}\n\nexport interface ManifestEntry {\n file_name: string | null;\n file_hash: string | null;\n download_url: string | null;\n}\n\nexport interface LatestVersion {\n /**\n * Result of getLatest method\n *\n * @since 4.0.0\n */\n version: string;\n /**\n * @since 6\n */\n checksum?: string;\n major?: boolean;\n message?: string;\n sessionKey?: string;\n error?: string;\n old?: string;\n url?: string;\n /**\n * @since 6.1\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleInfo {\n id: string;\n version: string;\n downloaded: string;\n checksum: string;\n status: BundleStatus;\n}\n\nexport interface SetChannelOptions {\n channel: string;\n triggerAutoUpdate?: boolean;\n}\n\nexport interface UnsetChannelOptions {\n triggerAutoUpdate?: boolean;\n}\n\nexport interface SetCustomIdOptions {\n /**\n * Custom identifier to associate with the device. Use an empty string to clear any saved value.\n */\n customId: string;\n}\n\nexport interface DelayCondition {\n /**\n * Set up delay conditions in setMultiDelay\n * @param value is useless for @param kind \"kill\", optional for \"background\" (default value: \"0\") and required for \"nativeVersion\" and \"date\"\n */\n kind: DelayUntilNext;\n value?: string;\n}\n\nexport interface GetLatestOptions {\n /**\n * The channel to get the latest version for\n * The channel must allow 'self_assign' for this to work\n * @since 6.8.0\n * @default undefined\n */\n channel?: string;\n}\n\nexport interface AppReadyResult {\n bundle: BundleInfo;\n}\n\nexport interface UpdateUrl {\n url: string;\n}\n\nexport interface StatsUrl {\n url: string;\n}\n\nexport interface ChannelUrl {\n url: string;\n}\n\n/**\n * This URL and versions are used to download the bundle from the server, If you use backend all information will be gived by the method getLatest.\n * If you don't use backend, you need to provide the URL and version of the bundle. Checksum and sessionKey are required if you encrypted the bundle with the CLI command encrypt, you should receive them as result of the command.\n */\nexport interface DownloadOptions {\n /**\n * The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.)\n */\n url: string;\n /**\n * The version code/name of this bundle/version\n */\n version: string;\n /**\n * The session key for the update, when the bundle is encrypted with a session key\n * @since 4.0.0\n * @default undefined\n */\n sessionKey?: string;\n /**\n * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted\n * @since 4.0.0\n * @default undefined\n */\n checksum?: string;\n /**\n * The manifest for multi-file downloads\n * @since 6.1.0\n * @default undefined\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleId {\n id: string;\n}\n\nexport interface BundleListResult {\n bundles: BundleInfo[];\n}\n\nexport interface ResetOptions {\n toLastSuccessful: boolean;\n}\n\nexport interface ListOptions {\n /**\n * Whether to return the raw bundle list or the manifest. If true, the list will attempt to read the internal database instead of files on disk.\n * @since 6.14.0\n * @default false\n */\n raw?: boolean;\n}\n\nexport interface CurrentBundleResult {\n bundle: BundleInfo;\n native: string;\n}\n\nexport interface MultiDelayConditions {\n delayConditions: DelayCondition[];\n}\n\nexport interface BuiltinVersion {\n version: string;\n}\n\nexport interface DeviceId {\n deviceId: string;\n}\n\nexport interface PluginVersion {\n version: string;\n}\n\nexport interface AutoUpdateEnabled {\n enabled: boolean;\n}\n\nexport interface AutoUpdateAvailable {\n available: boolean;\n}\n\nexport interface SetShakeMenuOptions {\n enabled: boolean;\n}\n\nexport interface ShakeMenuEnabled {\n enabled: boolean;\n}\n\nexport interface GetAppIdRes {\n appId: string;\n}\n\nexport interface SetAppIdOptions {\n appId: string;\n}\n"]}
@@ -6,6 +6,7 @@
6
6
 
7
7
  import Foundation
8
8
  import Capacitor
9
+ import UIKit
9
10
  import Version
10
11
 
11
12
  /**
@@ -50,7 +51,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
50
51
  CAPPluginMethod(name: "isShakeMenuEnabled", returnType: CAPPluginReturnPromise)
51
52
  ]
52
53
  public var implementation = CapgoUpdater()
53
- private let PLUGIN_VERSION: String = "7.18.14"
54
+ private let PLUGIN_VERSION: String = "7.19.1"
54
55
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
55
56
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
56
57
  static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
@@ -69,6 +70,12 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
69
70
  private var directUpdateMode: String = "false"
70
71
  private var wasRecentlyInstalledOrUpdated = false
71
72
  private var autoSplashscreen = false
73
+ private var autoSplashscreenLoader = false
74
+ private var autoSplashscreenTimeout = 10000
75
+ private var autoSplashscreenTimeoutWorkItem: DispatchWorkItem?
76
+ private var splashscreenLoaderView: UIActivityIndicatorView?
77
+ private var splashscreenLoaderContainer: UIView?
78
+ private var autoSplashscreenTimedOut = false
72
79
  private var autoDeleteFailed = false
73
80
  private var autoDeletePrevious = false
74
81
  private var keepUrlPathAfterReload = false
@@ -141,6 +148,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
141
148
  }
142
149
 
143
150
  autoSplashscreen = getConfig().getBoolean("autoSplashscreen", false)
151
+ autoSplashscreenLoader = getConfig().getBoolean("autoSplashscreenLoader", false)
152
+ let splashscreenTimeoutValue = getConfig().getInt("autoSplashscreenTimeout", 10000)
153
+ autoSplashscreenTimeout = max(0, splashscreenTimeoutValue)
144
154
  updateUrl = getConfig().getString("updateUrl", CapacitorUpdaterPlugin.updateUrlDefault)!
145
155
  autoUpdate = getConfig().getBoolean("autoUpdate", true)
146
156
  appReadyTimeout = getConfig().getInt("appReadyTimeout", 10000)
@@ -808,61 +818,204 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
808
818
  }
809
819
 
810
820
  private func hideSplashscreen() {
811
- DispatchQueue.main.async {
812
- guard let bridge = self.bridge else {
813
- self.logger.warn("Bridge not available for hiding splashscreen with autoSplashscreen")
814
- return
821
+ if Thread.isMainThread {
822
+ self.performHideSplashscreen()
823
+ } else {
824
+ DispatchQueue.main.async {
825
+ self.performHideSplashscreen()
815
826
  }
827
+ }
828
+ }
816
829
 
817
- // Create a plugin call for the hide method
818
- let call = CAPPluginCall(callbackId: "autoHideSplashscreen", options: [:], success: { (_, _) in
819
- self.logger.info("Splashscreen hidden automatically")
820
- }, error: { (_) in
821
- self.logger.error("Failed to auto-hide splashscreen")
822
- })
830
+ private func performHideSplashscreen() {
831
+ self.cancelSplashscreenTimeout()
832
+ self.removeSplashscreenLoader()
823
833
 
824
- // Try to call the SplashScreen hide method directly through the bridge
825
- if let splashScreenPlugin = bridge.plugin(withName: "SplashScreen") {
826
- // Use runtime method invocation to call hide method
827
- let selector = NSSelectorFromString("hide:")
828
- if splashScreenPlugin.responds(to: selector) {
829
- _ = splashScreenPlugin.perform(selector, with: call)
830
- self.logger.info("Called SplashScreen hide method")
831
- } else {
832
- self.logger.warn("autoSplashscreen: SplashScreen plugin does not respond to hide: method. Make sure @capacitor/splash-screen plugin is properly installed.")
833
- }
834
+ guard let bridge = self.bridge else {
835
+ self.logger.warn("Bridge not available for hiding splashscreen with autoSplashscreen")
836
+ return
837
+ }
838
+
839
+ // Create a plugin call for the hide method
840
+ let call = CAPPluginCall(callbackId: "autoHideSplashscreen", options: [:], success: { (_, _) in
841
+ self.logger.info("Splashscreen hidden automatically")
842
+ }, error: { (_) in
843
+ self.logger.error("Failed to auto-hide splashscreen")
844
+ })
845
+
846
+ // Try to call the SplashScreen hide method directly through the bridge
847
+ if let splashScreenPlugin = bridge.plugin(withName: "SplashScreen") {
848
+ // Use runtime method invocation to call hide method
849
+ let selector = NSSelectorFromString("hide:")
850
+ if splashScreenPlugin.responds(to: selector) {
851
+ _ = splashScreenPlugin.perform(selector, with: call)
852
+ self.logger.info("Called SplashScreen hide method")
834
853
  } else {
835
- self.logger.warn("autoSplashscreen: SplashScreen plugin not found. Install @capacitor/splash-screen plugin.")
854
+ self.logger.warn("autoSplashscreen: SplashScreen plugin does not respond to hide: method. Make sure @capacitor/splash-screen plugin is properly installed.")
836
855
  }
856
+ } else {
857
+ self.logger.warn("autoSplashscreen: SplashScreen plugin not found. Install @capacitor/splash-screen plugin.")
837
858
  }
838
859
  }
839
860
 
840
861
  private func showSplashscreen() {
841
- DispatchQueue.main.async {
842
- guard let bridge = self.bridge else {
843
- self.logger.warn("Bridge not available for showing splashscreen with autoSplashscreen")
862
+ if Thread.isMainThread {
863
+ self.performShowSplashscreen()
864
+ } else {
865
+ DispatchQueue.main.async {
866
+ self.performShowSplashscreen()
867
+ }
868
+ }
869
+ }
870
+
871
+ private func performShowSplashscreen() {
872
+ self.cancelSplashscreenTimeout()
873
+ self.autoSplashscreenTimedOut = false
874
+
875
+ guard let bridge = self.bridge else {
876
+ self.logger.warn("Bridge not available for showing splashscreen with autoSplashscreen")
877
+ return
878
+ }
879
+
880
+ // Create a plugin call for the show method
881
+ let call = CAPPluginCall(callbackId: "autoShowSplashscreen", options: [:], success: { (_, _) in
882
+ self.logger.info("Splashscreen shown automatically")
883
+ }, error: { (_) in
884
+ self.logger.error("Failed to auto-show splashscreen")
885
+ })
886
+
887
+ // Try to call the SplashScreen show method directly through the bridge
888
+ if let splashScreenPlugin = bridge.plugin(withName: "SplashScreen") {
889
+ // Use runtime method invocation to call show method
890
+ let selector = NSSelectorFromString("show:")
891
+ if splashScreenPlugin.responds(to: selector) {
892
+ _ = splashScreenPlugin.perform(selector, with: call)
893
+ self.logger.info("Called SplashScreen show method")
894
+ } else {
895
+ self.logger.warn("autoSplashscreen: SplashScreen plugin does not respond to show: method. Make sure @capacitor/splash-screen plugin is properly installed.")
896
+ }
897
+ } else {
898
+ self.logger.warn("autoSplashscreen: SplashScreen plugin not found. Install @capacitor/splash-screen plugin.")
899
+ }
900
+
901
+ self.addSplashscreenLoaderIfNeeded()
902
+ self.scheduleSplashscreenTimeout()
903
+ }
904
+
905
+ private func addSplashscreenLoaderIfNeeded() {
906
+ guard self.autoSplashscreenLoader else {
907
+ return
908
+ }
909
+
910
+ let addLoader = {
911
+ guard self.splashscreenLoaderContainer == nil else {
912
+ return
913
+ }
914
+ guard let rootView = self.bridge?.viewController?.view else {
915
+ self.logger.warn("autoSplashscreen: Unable to access root view for loader overlay")
844
916
  return
845
917
  }
846
918
 
847
- // Create a plugin call for the show method
848
- let call = CAPPluginCall(callbackId: "autoShowSplashscreen", options: [:], success: { (_, _) in
849
- self.logger.info("Splashscreen shown automatically")
850
- }, error: { (_) in
851
- self.logger.error("Failed to auto-show splashscreen")
852
- })
919
+ let container = UIView()
920
+ container.translatesAutoresizingMaskIntoConstraints = false
921
+ container.backgroundColor = UIColor.clear
922
+ container.isUserInteractionEnabled = false
853
923
 
854
- // Try to call the SplashScreen show method directly through the bridge
855
- if let splashScreenPlugin = bridge.plugin(withName: "SplashScreen") {
856
- // Use runtime method invocation to call show method
857
- let selector = NSSelectorFromString("show:")
858
- if splashScreenPlugin.responds(to: selector) {
859
- _ = splashScreenPlugin.perform(selector, with: call)
860
- self.logger.info("Called SplashScreen show method")
861
- } else {
862
- self.logger.warn("autoSplashscreen: SplashScreen plugin does not respond to show: method. Make sure @capacitor/splash-screen plugin is properly installed.")
863
- }
924
+ let indicatorStyle: UIActivityIndicatorView.Style
925
+ if #available(iOS 13.0, *) {
926
+ indicatorStyle = .large
864
927
  } else {
865
- self.logger.warn("autoSplashscreen: SplashScreen plugin not found. Install @capacitor/splash-screen plugin.")
928
+ indicatorStyle = .whiteLarge
929
+ }
930
+
931
+ let indicator = UIActivityIndicatorView(style: indicatorStyle)
932
+ indicator.translatesAutoresizingMaskIntoConstraints = false
933
+ indicator.hidesWhenStopped = false
934
+ if #available(iOS 13.0, *) {
935
+ indicator.color = UIColor.label
936
+ }
937
+ indicator.startAnimating()
938
+
939
+ container.addSubview(indicator)
940
+ rootView.addSubview(container)
941
+
942
+ NSLayoutConstraint.activate([
943
+ container.leadingAnchor.constraint(equalTo: rootView.leadingAnchor),
944
+ container.trailingAnchor.constraint(equalTo: rootView.trailingAnchor),
945
+ container.topAnchor.constraint(equalTo: rootView.topAnchor),
946
+ container.bottomAnchor.constraint(equalTo: rootView.bottomAnchor),
947
+ indicator.centerXAnchor.constraint(equalTo: container.centerXAnchor),
948
+ indicator.centerYAnchor.constraint(equalTo: container.centerYAnchor)
949
+ ])
950
+
951
+ self.splashscreenLoaderContainer = container
952
+ self.splashscreenLoaderView = indicator
953
+ }
954
+
955
+ if Thread.isMainThread {
956
+ addLoader()
957
+ } else {
958
+ DispatchQueue.main.async {
959
+ addLoader()
960
+ }
961
+ }
962
+ }
963
+
964
+ private func removeSplashscreenLoader() {
965
+ let removeLoader = {
966
+ self.splashscreenLoaderView?.stopAnimating()
967
+ self.splashscreenLoaderContainer?.removeFromSuperview()
968
+ self.splashscreenLoaderView = nil
969
+ self.splashscreenLoaderContainer = nil
970
+ }
971
+
972
+ if Thread.isMainThread {
973
+ removeLoader()
974
+ } else {
975
+ DispatchQueue.main.async {
976
+ removeLoader()
977
+ }
978
+ }
979
+ }
980
+
981
+ private func scheduleSplashscreenTimeout() {
982
+ guard self.autoSplashscreenTimeout > 0 else {
983
+ return
984
+ }
985
+
986
+ let scheduleTimeout = {
987
+ self.autoSplashscreenTimeoutWorkItem?.cancel()
988
+
989
+ let workItem = DispatchWorkItem { [weak self] in
990
+ guard let self = self else { return }
991
+ self.autoSplashscreenTimedOut = true
992
+ self.logger.info("autoSplashscreen timeout reached, hiding splashscreen")
993
+ self.hideSplashscreen()
994
+ }
995
+ self.autoSplashscreenTimeoutWorkItem = workItem
996
+ DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(self.autoSplashscreenTimeout), execute: workItem)
997
+ }
998
+
999
+ if Thread.isMainThread {
1000
+ scheduleTimeout()
1001
+ } else {
1002
+ DispatchQueue.main.async {
1003
+ scheduleTimeout()
1004
+ }
1005
+ }
1006
+ }
1007
+
1008
+ private func cancelSplashscreenTimeout() {
1009
+ let cancelTimeout = {
1010
+ self.autoSplashscreenTimeoutWorkItem?.cancel()
1011
+ self.autoSplashscreenTimeoutWorkItem = nil
1012
+ }
1013
+
1014
+ if Thread.isMainThread {
1015
+ cancelTimeout()
1016
+ } else {
1017
+ DispatchQueue.main.async {
1018
+ cancelTimeout()
866
1019
  }
867
1020
  }
868
1021
  }
@@ -884,6 +1037,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
884
1037
  }
885
1038
 
886
1039
  private func shouldUseDirectUpdate() -> Bool {
1040
+ if self.autoSplashscreenTimedOut {
1041
+ return false
1042
+ }
887
1043
  switch directUpdateMode {
888
1044
  case "false":
889
1045
  return false
@@ -920,8 +1076,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
920
1076
  }
921
1077
 
922
1078
  func backgroundDownload() {
923
- let shouldDirectUpdate = self.shouldUseDirectUpdate()
924
- let messageUpdate = shouldDirectUpdate ? "Update will occur now." : "Update will occur next time app moves to background."
1079
+ let plannedDirectUpdate = self.shouldUseDirectUpdate()
1080
+ let messageUpdate = plannedDirectUpdate ? "Update will occur now." : "Update will occur next time app moves to background."
925
1081
  guard let url = URL(string: self.updateUrl) else {
926
1082
  logger.error("Error no url or wrong format")
927
1083
  return
@@ -975,11 +1131,15 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
975
1131
  }
976
1132
  if res.version == "builtin" {
977
1133
  self.logger.info("Latest version is builtin")
978
- if shouldDirectUpdate {
1134
+ let directUpdateAllowed = plannedDirectUpdate && !self.autoSplashscreenTimedOut
1135
+ if directUpdateAllowed {
979
1136
  self.logger.info("Direct update to builtin version")
980
1137
  _ = self._reset(toLastSuccessful: false)
981
1138
  self.endBackGroundTaskWithNotif(msg: "Updated to builtin version", latestVersionName: res.version, current: self.implementation.getCurrentBundle(), error: false)
982
1139
  } else {
1140
+ if plannedDirectUpdate && !directUpdateAllowed {
1141
+ self.logger.info("Direct update skipped because splashscreen timeout occurred. Update will apply later.")
1142
+ }
983
1143
  self.logger.info("Setting next bundle to builtin")
984
1144
  _ = self.implementation.setNextBundle(next: BundleInfo.ID_BUILTIN)
985
1145
  self.endBackGroundTaskWithNotif(msg: "Next update will be to builtin version", latestVersionName: res.version, current: current, error: false)
@@ -1035,7 +1195,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1035
1195
  self.endBackGroundTaskWithNotif(msg: "Error checksum", latestVersionName: latestVersionName, current: current)
1036
1196
  return
1037
1197
  }
1038
- if shouldDirectUpdate {
1198
+ let directUpdateAllowed = plannedDirectUpdate && !self.autoSplashscreenTimedOut
1199
+ if directUpdateAllowed {
1039
1200
  let delayUpdatePreferences = UserDefaults.standard.string(forKey: DelayUpdateUtils.DELAY_CONDITION_PREFERENCES) ?? "[]"
1040
1201
  let delayConditionList: [DelayCondition] = self.fromJsonArr(json: delayUpdatePreferences).map { obj -> DelayCondition in
1041
1202
  let kind: String = obj.value(forKey: "kind") as! String
@@ -1051,6 +1212,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1051
1212
  _ = self._reload()
1052
1213
  self.endBackGroundTaskWithNotif(msg: "update installed", latestVersionName: latestVersionName, current: next, error: false)
1053
1214
  } else {
1215
+ if plannedDirectUpdate && !directUpdateAllowed {
1216
+ self.logger.info("Direct update skipped because splashscreen timeout occurred. Update will install on next app background.")
1217
+ }
1054
1218
  self.notifyListeners("updateAvailable", data: ["bundle": next.toJSON()])
1055
1219
  _ = self.implementation.setNextBundle(next: next.getId())
1056
1220
  self.endBackGroundTaskWithNotif(msg: "update downloaded, will install next background", latestVersionName: latestVersionName, current: current, error: false)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "7.18.14",
3
+ "version": "7.19.1",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",