Skip to content

Commit

Permalink
fix(iOS): subscribe to orientation changes only on iOS (#46531)
Browse files Browse the repository at this point in the history
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: #46531

Test Plan: CI Green

Reviewed By: philIip

Differential Revision: D62864013

Pulled By: cipolleschi

fbshipit-source-id: 341df9ac765735273378d017b63fcb7a4d8e98e5
  • Loading branch information
okwasniewski authored and facebook-github-bot committed Sep 18, 2024
1 parent 6d61899 commit 2f5adc3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/react-native/React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -265,6 +267,7 @@ - (void)didReceiveNewContentSizeMultiplier
};
}

#if TARGET_OS_IOS
- (void)namedOrientationDidChange
{
NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation);
Expand All @@ -278,6 +281,7 @@ - (void)namedOrientationDidChange
body:orientationEvent];
#pragma clang diagnostic pop
}
#endif

- (dispatch_queue_t)methodQueue
{
Expand Down

0 comments on commit 2f5adc3

Please sign in to comment.