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
This commit is contained in:
Oskar Kwaśniewski
2024-09-18 03:28:26 -07:00
committed by Facebook GitHub Bot
parent 6d61899fc5
commit 2f5adc3874
@@ -196,10 +196,12 @@ RCT_EXPORT_MODULE()
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 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
};
}
#if TARGET_OS_IOS
- (void)namedOrientationDidChange
{
NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation);
@@ -278,6 +281,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
body:orientationEvent];
#pragma clang diagnostic pop
}
#endif
- (dispatch_queue_t)methodQueue
{