diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift index 01115c80..e13cfeba 100644 --- a/ios/App/App/AppDelegate.swift +++ b/ios/App/App/AppDelegate.swift @@ -5,7 +5,7 @@ import RealmSwift @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { - var window: UIWindow? + lazy var window: UIWindow? = UIWindow(frame: UIScreen.main.bounds) var backgroundCompletionHandler: (() -> Void)? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { @@ -83,10 +83,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { override func touchesBegan(_ touches: Set, with event: UIEvent?) { super.touchesBegan(touches, with: event) - let statusBarRect = UIApplication.shared.statusBarFrame + let statusBarRect = self.window?.windowScene?.statusBarManager?.statusBarFrame guard let touchPoint = event?.allTouches?.first?.location(in: self.window) else { return } - if statusBarRect.contains(touchPoint) { + if statusBarRect?.contains(touchPoint) ?? false { NotificationCenter.default.post(name: .capacitorStatusBarTapped, object: nil) } }