From 2f5adc3874bcdfc8d7d2c3cd5293eefec63a91f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Wed, 18 Sep 2024 03:28:26 -0700 Subject: [PATCH] fix(iOS): subscribe to orientation changes only on iOS (#46531) Summary: This PR adds iOS ifdefs to `RCTUIManager` to subscribe to orientation changes on this platform. The `UIDeviceOrientationDidChangeNotification` symbol is only available there. ## Changelog: [IOS] [FIXED] - subscribe to orientation changes in RCTUIManager only on iOS Pull Request resolved: https://github.com/facebook/react-native/pull/46531 Test Plan: CI Green Reviewed By: philIip Differential Revision: D62864013 Pulled By: cipolleschi fbshipit-source-id: 341df9ac765735273378d017b63fcb7a4d8e98e5 --- packages/react-native/React/Modules/RCTUIManager.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/React/Modules/RCTUIManager.m b/packages/react-native/React/Modules/RCTUIManager.m index 31c12fd22789bb..2d47cafe9e807e 100644 --- a/packages/react-native/React/Modules/RCTUIManager.m +++ b/packages/react-native/React/Modules/RCTUIManager.m @@ -196,10 +196,12 @@ - (void)setBridge:(RCTBridge *)bridge name:@"RCTAccessibilityManagerDidUpdateMultiplierNotification" object:a11yManager]; }); +#if TARGET_OS_IOS [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(namedOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil]; +#endif [RCTLayoutAnimation initializeStatics]; } @@ -265,6 +267,7 @@ - (void)didReceiveNewContentSizeMultiplier }; } +#if TARGET_OS_IOS - (void)namedOrientationDidChange { NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation); @@ -278,6 +281,7 @@ - (void)namedOrientationDidChange body:orientationEvent]; #pragma clang diagnostic pop } +#endif - (dispatch_queue_t)methodQueue {