diff --git a/packages/react-native/React/Base/UIKitProxies/RCTWindowSafeAreaProxy.mm b/packages/react-native/React/Base/UIKitProxies/RCTWindowSafeAreaProxy.mm index 057edaa6713..440514a5088 100644 --- a/packages/react-native/React/Base/UIKitProxies/RCTWindowSafeAreaProxy.mm +++ b/packages/react-native/React/Base/UIKitProxies/RCTWindowSafeAreaProxy.mm @@ -34,7 +34,7 @@ std::lock_guard lock(_mutex); if (!_isObserving) { _isObserving = YES; - _currentSafeAreaInsets = [UIApplication sharedApplication].delegate.window.safeAreaInsets; + _currentSafeAreaInsets = RCTKeyWindow().safeAreaInsets; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_interfaceFrameDidChange) name:RCTUserInterfaceStyleDidChangeNotification @@ -64,7 +64,7 @@ - (void)_interfaceFrameDidChange { std::lock_guard lock(_mutex); - _currentSafeAreaInsets = [UIApplication sharedApplication].delegate.window.safeAreaInsets; + _currentSafeAreaInsets = RCTKeyWindow().safeAreaInsets; } @end diff --git a/packages/react-native/React/CoreModules/RCTDeviceInfo.mm b/packages/react-native/React/CoreModules/RCTDeviceInfo.mm index 8761904c55b..6b4fcef8522 100644 --- a/packages/react-native/React/CoreModules/RCTDeviceInfo.mm +++ b/packages/react-native/React/CoreModules/RCTDeviceInfo.mm @@ -209,11 +209,10 @@ static NSDictionary *RCTExportedDimensions(CGFloat fontScale) - (void)interfaceOrientationDidChange { #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST - UIApplication *application = RCTSharedApplication(); - UIInterfaceOrientation nextOrientation = RCTKeyWindow().windowScene.interfaceOrientation; + UIWindow *keyWindow = RCTKeyWindow(); + UIInterfaceOrientation nextOrientation = keyWindow.windowScene.interfaceOrientation; - BOOL isRunningInFullScreen = - CGRectEqualToRect(application.delegate.window.frame, application.delegate.window.screen.bounds); + BOOL isRunningInFullScreen = CGRectEqualToRect(keyWindow.frame, keyWindow.screen.bounds); // We are catching here two situations for multitasking view: // a) The app is in Split View and the container gets resized -> !isRunningInFullScreen // b) The app changes to/from fullscreen example: App runs in slide over mode and goes into fullscreen-> diff --git a/packages/react-native/React/CoreModules/RCTRedBox.mm b/packages/react-native/React/CoreModules/RCTRedBox.mm index d427c053cda..fb057b96921 100644 --- a/packages/react-native/React/CoreModules/RCTRedBox.mm +++ b/packages/react-native/React/CoreModules/RCTRedBox.mm @@ -222,7 +222,7 @@ #if TARGET_OS_MACCATALYST return 0; #else - return RCTSharedApplication().delegate.window.safeAreaInsets.bottom; + return RCTKeyWindow().safeAreaInsets.bottom; #endif }