diff --git a/ios/ReactTestApp/React+Compatibility.m b/ios/ReactTestApp/React+Compatibility.m index 6639d28cf..b39c4b2ac 100644 --- a/ios/ReactTestApp/React+Compatibility.m +++ b/ios/ReactTestApp/React+Compatibility.m @@ -90,3 +90,45 @@ - (void)rta_displayLayer:(CALayer *)layer @end #endif // !TARGET_OS_OSX && REACT_NATIVE_VERSION < 6302 + +// MARK: - [0.70.0] Alerts don't show when using UIScene +// See https://github.com/facebook/react-native/pull/34562 + +#if !TARGET_OS_OSX && REACT_NATIVE_VERSION < 7100 + +#import +#import + +@implementation RCTAlertController (ReactTestApp) + ++ (void)initialize +{ + if ([self class] != [RCTAlertController class]) { + return; + } + + if (@available(iOS 13.0, *)) { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + RTASwizzleSelector([self class], @selector(hide), @selector(rta_hide)); + RTASwizzleSelector( + [self class], @selector(show:completion:), @selector(rta_show:completion:)); + }); + } +} + +- (void)rta_hide +{ + // noop +} + +- (void)rta_show:(BOOL)animated completion:(void (^)(void))completion +{ + [[RCTKeyWindow() rootViewController] presentViewController:self + animated:animated + completion:completion]; +} + +@end + +#endif // !TARGET_OS_OSX && REACT_NATIVE_VERSION < 7100