From 05c4321b194c3d0e146b6085bcaccc75acd3fd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Tue, 2 Sep 2025 11:19:42 -0700 Subject: [PATCH] fix: fallback alert controller to UIScreen size (#53500) Summary: This PR falls back to UIScreen when windowScene is not available. CleanShot 2025-08-28 at 14 30 59@2x ## Changelog: [IOS] [FIXED] - Simplify RCTAlertController, don't create additional UIWindow Pull Request resolved: https://github.com/facebook/react-native/pull/53500 Test Plan: Open the alert multiple times to check if everything works as expected. Rollback Plan: Reviewed By: javache Differential Revision: D81410450 Pulled By: cipolleschi fbshipit-source-id: c27ea98d9e811c2f259f0ff3c6689482d116c418 --- .../react-native/React/CoreModules/RCTAlertController.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-native/React/CoreModules/RCTAlertController.mm b/packages/react-native/React/CoreModules/RCTAlertController.mm index b47ce0adefa..3131ff4db59 100644 --- a/packages/react-native/React/CoreModules/RCTAlertController.mm +++ b/packages/react-native/React/CoreModules/RCTAlertController.mm @@ -20,7 +20,12 @@ - (UIWindow *)alertWindow { if (_alertWindow == nil) { - _alertWindow = [[UIWindow alloc] initWithWindowScene:RCTKeyWindow().windowScene]; + UIWindowScene *scene = RCTKeyWindow().windowScene; + if (scene != nil) { + _alertWindow = [[UIWindow alloc] initWithWindowScene:scene]; + } else { + _alertWindow = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; + } if (_alertWindow) { _alertWindow.rootViewController = [UIViewController new];