@capgo/capacitor-updater 8.51.6 → 8.51.8

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.
@@ -50,7 +50,7 @@ repositories {
50
50
 
51
51
  dependencies {
52
52
  def work_version = "2.10.5"
53
- def lifecycle_version = "2.11.0"
53
+ def lifecycle_version = "2.10.0"
54
54
  implementation "androidx.work:work-runtime:$work_version"
55
55
  implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
56
56
  implementation "com.google.android.gms:play-services-tasks:18.4.1"
@@ -146,7 +146,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
146
146
  static final int APPLICATION_EXIT_REASON_USER_REQUESTED = 10;
147
147
  static final int APPLICATION_EXIT_REASON_DEPENDENCY_DIED = 12;
148
148
 
149
- private final String pluginVersion = "8.51.6";
149
+ private final String pluginVersion = "8.51.8";
150
150
  private static final String DELAY_CONDITION_PREFERENCES = "";
151
151
 
152
152
  private SharedPreferences.Editor editor;
@@ -96,7 +96,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
96
96
  deinit {
97
97
  implementation.shutdown()
98
98
  }
99
- private let pluginVersion: String = "8.51.6"
99
+ private let pluginVersion: String = "8.51.8"
100
100
  private let launchStartedAtMs = Int64(Date().timeIntervalSince1970 * 1000)
101
101
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
102
102
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
@@ -92,18 +92,26 @@ final class ThreeFingerPinchGestureRecognizer: UIGestureRecognizer {
92
92
  }
93
93
 
94
94
  extension UIApplication {
95
- // swiftlint:disable:next line_length
96
- public class func topViewController(_ base: UIViewController? = UIApplication.shared.windows.first?.rootViewController) -> UIViewController? {
97
- if let nav = base as? UINavigationController {
95
+ public class func topViewController(_ base: UIViewController? = nil) -> UIViewController? {
96
+ let resolvedBase = base ?? keyWindowRootViewController
97
+ if let nav = resolvedBase as? UINavigationController {
98
98
  return topViewController(nav.visibleViewController)
99
99
  }
100
- if let tab = base as? UITabBarController, let selected = tab.selectedViewController {
100
+ if let tab = resolvedBase as? UITabBarController, let selected = tab.selectedViewController {
101
101
  return topViewController(selected)
102
102
  }
103
- if let presented = base?.presentedViewController {
103
+ if let presented = resolvedBase?.presentedViewController {
104
104
  return topViewController(presented)
105
105
  }
106
- return base
106
+ return resolvedBase
107
+ }
108
+
109
+ private static var keyWindowRootViewController: UIViewController? {
110
+ let scenes = shared.connectedScenes.compactMap { $0 as? UIWindowScene }
111
+ let foregroundScenes = scenes.filter { $0.activationState == .foregroundActive }
112
+ let candidates = foregroundScenes.isEmpty ? scenes : foregroundScenes
113
+ let window = candidates.flatMap(\.windows).first(where: \.isKeyWindow) ?? candidates.first?.windows.first
114
+ return window?.rootViewController
107
115
  }
108
116
  }
109
117
 
@@ -184,6 +192,10 @@ extension CapacitorUpdaterPlugin: UIGestureRecognizerDelegate {
184
192
  }
185
193
 
186
194
  extension UIWindow {
195
+ private var menuHostViewController: UIViewController? {
196
+ UIApplication.topViewController(rootViewController)
197
+ }
198
+
187
199
  override open func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
188
200
  if motion == .motionShake {
189
201
  guard let bridgeViewController = rootViewController as? CAPBridgeViewController,
@@ -230,7 +242,7 @@ extension UIWindow {
230
242
  @discardableResult
231
243
  private func showDefaultMenu(plugin: CapacitorUpdaterPlugin, bridge: CAPBridgeProtocol) -> Bool {
232
244
  // Prevent multiple alerts from showing
233
- guard let topVC = UIApplication.topViewController() else {
245
+ guard let topVC = self.menuHostViewController else {
234
246
  return false
235
247
  }
236
248
  if topVC.isKind(of: UIAlertController.self) {
@@ -365,7 +377,7 @@ extension UIWindow {
365
377
  })
366
378
 
367
379
  DispatchQueue.main.async {
368
- if let topVC = UIApplication.topViewController() {
380
+ if let topVC = self.menuHostViewController {
369
381
  topVC.present(alertShake, animated: true)
370
382
  }
371
383
  }
@@ -388,7 +400,7 @@ extension UIWindow {
388
400
  }
389
401
 
390
402
  private func showPreviewSelector(plugin: CapacitorUpdaterPlugin) {
391
- guard let topVC = UIApplication.topViewController() else {
403
+ guard let topVC = self.menuHostViewController else {
392
404
  return
393
405
  }
394
406
  if topVC.isKind(of: UIAlertController.self) {
@@ -456,7 +468,7 @@ extension UIWindow {
456
468
  alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
457
469
 
458
470
  DispatchQueue.main.async {
459
- if let topVC = UIApplication.topViewController() {
471
+ if let topVC = self.menuHostViewController {
460
472
  topVC.present(alert, animated: true)
461
473
  }
462
474
  }
@@ -479,7 +491,7 @@ extension UIWindow {
479
491
  }
480
492
 
481
493
  DispatchQueue.main.async {
482
- if let topVC = UIApplication.topViewController() {
494
+ if let topVC = self.menuHostViewController {
483
495
  topVC.present(alert, animated: true)
484
496
  }
485
497
  }
@@ -498,7 +510,7 @@ extension UIWindow {
498
510
  @discardableResult
499
511
  private func showChannelSelector(plugin: CapacitorUpdaterPlugin, bridge: CAPBridgeProtocol) -> Bool {
500
512
  // Prevent multiple alerts from showing
501
- guard let topVC = UIApplication.topViewController() else {
513
+ guard let topVC = self.menuHostViewController else {
502
514
  return false
503
515
  }
504
516
  if topVC.isKind(of: UIAlertController.self) {
@@ -582,7 +594,7 @@ extension UIWindow {
582
594
  }
583
595
 
584
596
  DispatchQueue.main.async {
585
- if let topVC = UIApplication.topViewController() {
597
+ if let topVC = self.menuHostViewController {
586
598
  topVC.present(alert, animated: true)
587
599
  }
588
600
  }
@@ -627,7 +639,7 @@ extension UIWindow {
627
639
  alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
628
640
 
629
641
  DispatchQueue.main.async {
630
- if let topVC = UIApplication.topViewController() {
642
+ if let topVC = self.menuHostViewController {
631
643
  topVC.present(alert, animated: true)
632
644
  }
633
645
  }
@@ -649,7 +661,7 @@ extension UIWindow {
649
661
  ])
650
662
 
651
663
  DispatchQueue.main.async {
652
- if let topVC = UIApplication.topViewController() {
664
+ if let topVC = self.menuHostViewController {
653
665
  topVC.present(progressAlert, animated: true) {
654
666
  DispatchQueue.global(qos: .userInitiated).async {
655
667
  // Set the channel - respect plugin's allowSetDefaultChannel config
@@ -806,7 +818,7 @@ extension UIWindow {
806
818
  alert.addAction(UIAlertAction(title: "OK", style: .default))
807
819
 
808
820
  DispatchQueue.main.async {
809
- if let topVC = UIApplication.topViewController() {
821
+ if let topVC = self.menuHostViewController {
810
822
  topVC.present(alert, animated: true)
811
823
  }
812
824
  }
@@ -818,7 +830,7 @@ extension UIWindow {
818
830
  alert.addAction(UIAlertAction(title: "OK", style: .default))
819
831
 
820
832
  DispatchQueue.main.async {
821
- if let topVC = UIApplication.topViewController() {
833
+ if let topVC = self.menuHostViewController {
822
834
  topVC.present(alert, animated: true)
823
835
  }
824
836
  }
@@ -844,7 +856,7 @@ extension UIWindow {
844
856
  })
845
857
 
846
858
  DispatchQueue.main.async {
847
- if let topVC = UIApplication.topViewController() {
859
+ if let topVC = self.menuHostViewController {
848
860
  topVC.present(alert, animated: true)
849
861
  }
850
862
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "8.51.6",
3
+ "version": "8.51.8",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",
@@ -81,11 +81,11 @@
81
81
  "generate:rsa-contract": "bun scripts/generate-rsa-contract-fixtures.mjs"
82
82
  },
83
83
  "devDependencies": {
84
- "@capacitor/android": "^8.0.0",
85
- "@capacitor/cli": "^8.0.0",
86
- "@capacitor/core": "^8.0.0",
84
+ "@capacitor/android": "^8.5.0",
85
+ "@capacitor/cli": "^8.5.0",
86
+ "@capacitor/core": "^8.5.0",
87
87
  "@capacitor/docgen": "^0.3.0",
88
- "@capacitor/ios": "^8.0.0",
88
+ "@capacitor/ios": "^8.5.0",
89
89
  "@ionic/eslint-config": "^0.4.0",
90
90
  "@ionic/prettier-config": "^4.0.0",
91
91
  "@ionic/swiftlint-config": "^2.0.0",