diff --git a/React/CoreModules/RCTAlertController.h b/React/CoreModules/RCTAlertController.h index 62adf2f3ac9e03..74e183da79125c 100644 --- a/React/CoreModules/RCTAlertController.h +++ b/React/CoreModules/RCTAlertController.h @@ -10,6 +10,5 @@ @interface RCTAlertController : UIAlertController - (void)show:(BOOL)animated completion:(void (^)(void))completion; -- (void)hide; @end diff --git a/React/CoreModules/RCTAlertController.m b/React/CoreModules/RCTAlertController.m index 02636c3f4a7b8f..fc531b3a331d5c 100644 --- a/React/CoreModules/RCTAlertController.m +++ b/React/CoreModules/RCTAlertController.m @@ -9,24 +9,8 @@ #import -@interface RCTAlertController () - -@property (nonatomic, strong) UIWindow *alertWindow; - -@end - @implementation RCTAlertController -- (UIWindow *)alertWindow -{ - if (_alertWindow == nil) { - _alertWindow = [[UIWindow alloc] initWithFrame:RCTSharedApplication().keyWindow.bounds]; - _alertWindow.rootViewController = [UIViewController new]; - _alertWindow.windowLevel = UIWindowLevelAlert + 1; - } - return _alertWindow; -} - - (void)show:(BOOL)animated completion:(void (^)(void))completion { if (@available(iOS 13.0, *)) { @@ -34,19 +18,7 @@ - (void)show:(BOOL)animated completion:(void (^)(void))completion RCTSharedApplication().delegate.window.overrideUserInterfaceStyle ?: UIUserInterfaceStyleUnspecified; self.overrideUserInterfaceStyle = style; } - [self.alertWindow makeKeyAndVisible]; - [self.alertWindow.rootViewController presentViewController:self animated:animated completion:completion]; -} - -- (void)hide -{ - [_alertWindow setHidden:YES]; - - if (@available(iOS 13, *)) { - _alertWindow.windowScene = nil; - } - - _alertWindow = nil; + [[RCTKeyWindow() rootViewController] presentViewController:self animated:animated completion:completion]; } @end diff --git a/React/CoreModules/RCTAlertManager.mm b/React/CoreModules/RCTAlertManager.mm index 532e898faf05a0..25ab71f913b73e 100644 --- a/React/CoreModules/RCTAlertManager.mm +++ b/React/CoreModules/RCTAlertManager.mm @@ -185,7 +185,6 @@ - (void)invalidate case RCTAlertViewStylePlainTextInput: case RCTAlertViewStyleSecureTextInput: callback(@[ buttonKey, [weakAlertController.textFields.firstObject text] ]); - [weakAlertController hide]; break; case RCTAlertViewStyleLoginAndPasswordInput: { NSDictionary *loginCredentials = @{ @@ -193,12 +192,10 @@ - (void)invalidate @"password" : [weakAlertController.textFields.lastObject text] }; callback(@[ buttonKey, loginCredentials ]); - [weakAlertController hide]; break; } case RCTAlertViewStyleDefault: callback(@[ buttonKey ]); - [weakAlertController hide]; break; } }];