diff --git a/packages/react-native/React/CoreModules/RCTStatusBarManager.mm b/packages/react-native/React/CoreModules/RCTStatusBarManager.mm index 5d5318fb4148c7..29309135309eac 100644 --- a/packages/react-native/React/CoreModules/RCTStatusBarManager.mm +++ b/packages/react-native/React/CoreModules/RCTStatusBarManager.mm @@ -92,11 +92,6 @@ - (void)stopObserving [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (dispatch_queue_t)methodQueue -{ - return dispatch_get_main_queue(); -} - - (void)emitEvent:(NSString *)eventName forNotification:(NSNotification *)notification { CGRect frame = [notification.userInfo[UIApplicationStatusBarFrameUserInfoKey] CGRectValue]; @@ -130,35 +125,41 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification RCT_EXPORT_METHOD(setStyle : (NSString *)style animated : (BOOL)animated) { - UIStatusBarStyle statusBarStyle = [RCTConvert UIStatusBarStyle:style]; - if (RCTViewControllerBasedStatusBarAppearance()) { - RCTLogError(@"RCTStatusBarManager module requires that the \ + dispatch_async(dispatch_get_main_queue(), ^{ + UIStatusBarStyle statusBarStyle = [RCTConvert UIStatusBarStyle:style]; + if (RCTViewControllerBasedStatusBarAppearance()) { + RCTLogError(@"RCTStatusBarManager module requires that the \ UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); - } else { + } else { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [RCTSharedApplication() setStatusBarStyle:statusBarStyle animated:animated]; - } + [RCTSharedApplication() setStatusBarStyle:statusBarStyle animated:animated]; + } #pragma clang diagnostic pop + }); } RCT_EXPORT_METHOD(setHidden : (BOOL)hidden withAnimation : (NSString *)withAnimation) { - UIStatusBarAnimation animation = [RCTConvert UIStatusBarAnimation:withAnimation]; - if (RCTViewControllerBasedStatusBarAppearance()) { - RCTLogError(@"RCTStatusBarManager module requires that the \ + dispatch_async(dispatch_get_main_queue(), ^{ + UIStatusBarAnimation animation = [RCTConvert UIStatusBarAnimation:withAnimation]; + if (RCTViewControllerBasedStatusBarAppearance()) { + RCTLogError(@"RCTStatusBarManager module requires that the \ UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); - } else { + } else { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [RCTSharedApplication() setStatusBarHidden:hidden withAnimation:animation]; + [RCTSharedApplication() setStatusBarHidden:hidden withAnimation:animation]; #pragma clang diagnostic pop - } + } + }); } RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible : (BOOL)visible) { - RCTSharedApplication().networkActivityIndicatorVisible = visible; + dispatch_async(dispatch_get_main_queue(), ^{ + RCTSharedApplication().networkActivityIndicatorVisible = visible; + }); } - (facebook::react::ModuleConstants)getConstants