From b2fba371df0edafbb3323188004fc1f6d9ab1e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Wed, 6 Mar 2024 07:07:53 -0800 Subject: [PATCH] feat: optimize RCTKeyWindow() for iOS 15+ (#43066) Summary: This PR further optimizes RCTKeyWindow() for iOS 15+ removing the need for additional loop bypass-github-export-checks ## Changelog: [IOS] [ADDED] - optimize RCTKeyWindow() for iOS 15+ Pull Request resolved: https://github.com/facebook/react-native/pull/43066 Test Plan: Launch RNTester, check if proper keyWindow is returned for iOS 15+ Reviewed By: javache Differential Revision: D54541838 Pulled By: cipolleschi fbshipit-source-id: be79ff48f825d10c8fd71efc18629377aadc29fd --- packages/react-native/React/Base/RCTUtils.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/React/Base/RCTUtils.m b/packages/react-native/React/Base/RCTUtils.m index 96e59e2db10181..716b5439ad0129 100644 --- a/packages/react-native/React/Base/RCTUtils.m +++ b/packages/react-native/React/Base/RCTUtils.m @@ -569,6 +569,10 @@ BOOL RCTRunningInAppExtension(void) } UIWindowScene *windowScene = (UIWindowScene *)scene; + if (@available(iOS 15.0, *)) { + return windowScene.keyWindow; + } + for (UIWindow *window in windowScene.windows) { if (window.isKeyWindow) { return window;