feat(ios): update the way to get keyWindow (#3448)

* feat(ios): update the way to get `keyWindow`

* lint
This commit is contained in:
Krzysztof Moch
2023-12-28 12:58:25 +01:00
committed by GitHub
parent 1a9ea827c0
commit f35727f30e
3 changed files with 26 additions and 5 deletions

View File

@@ -348,4 +348,16 @@ enum RCTVideoUtils {
return nil
}
static func getCurrentWindow() -> UIWindow? {
if #available(iOS 13.0, tvOS 13, *) {
return UIApplication.shared.connectedScenes
.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
.last { $0.isKeyWindow }
} else {
#if !os(visionOS)
return UIApplication.shared.keyWindow
#endif
}
}
}