From d3339a7f3a50e9c5937cfc27404cd160037a0790 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 4 Mar 2025 12:13:04 +0100 Subject: [PATCH] fix: iOS/iPadOS crashes on a start of the app because of there's no keyFrame set (#1448) So setting one if it's not set. --- client/platforms/ios/ScreenProtection.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/platforms/ios/ScreenProtection.swift b/client/platforms/ios/ScreenProtection.swift index 1355dc13..200cf0cb 100644 --- a/client/platforms/ios/ScreenProtection.swift +++ b/client/platforms/ios/ScreenProtection.swift @@ -14,10 +14,15 @@ extension UIApplication { var keyWindows: [UIWindow] { connectedScenes .compactMap { + guard let windowScene = $0 as? UIWindowScene else { return nil } if #available(iOS 15.0, *) { - ($0 as? UIWindowScene)?.keyWindow + guard let keywindow = windowScene.keyWindow else { + windowScene.windows.first?.makeKey() + return windowScene.windows.first + } + return keywindow } else { - ($0 as? UIWindowScene)?.windows.first { $0.isKeyWindow } + return windowScene.windows.first { $0.isKeyWindow } } } }