Fix useWindowDimensions not updating because of delayed applicationState update on iOS devices
Summary:
Issue
When a real device is oriented into landscape and the user locks the screen during said orientation incase the user rotates back to previous orientation and unlocks the screen useWindowDimensions will not get the correctly updated values. This is due to applicationState being equal to UIApplicationStateInactive still when interfaceFrameDidChange gets called.
Fix
didUpdateDimensions on iOS. Now correctly emits the dimension values after the device has been oriented and device has been locked. By adding UIDeviceOrientationDidChangeNotification to NSNotificationCenter
Changelog:
// RCTDeviceInfo.mm
// Adds the interfaceFrameDidChange to UIDeviceOrientationDidChangeNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(interfaceFrameDidChange)
name:UIDeviceOrientationDidChangeNotification
object:nil];
[IOS] [FIXED] - Emit didUpdateDimensions correctly
Test Plan:
Note: This doesn't seem to be replicable on simulators. It only happens on real iOS devices.
Before change:
Rotate Device > Lock Screen > Rotate back to portrait > Unlock phone
After change:
Same steps as above, now emits correct values