Fix deprecated and early window access warnings

This commit is contained in:
ronaldheft 2022-09-08 19:51:35 -04:00
parent 9dd532285c
commit 713999eb83
No known key found for this signature in database

View file

@ -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<UITouch>, 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)
}
}