Version 1.2.0 does not pass in _onOrientationDidChange
Hello,
react-native-orientation-locker module in our project got updated to version 1.2.0, we were using version 1.1.8 before. Since the update when the app rotates we do not pass in _onOrientationDidChange, is this a known issue? I do not see any errors while building and running the app. When the app starts it also is getting the orientation from Orientation.getOrientation() For now I will continue to use 1.1.8
The project uses RN 0.62.2.
If more info is needed please let me know.
Hey @bobdeprez , there is breaking changes in 1.2.0 related to #131. Please add this code to onCreate of MainApplication
registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance());
Could you please check if it works. Thanks!
Hello, this does not work, still _orientationDidChange is not called when changing orientation. I use Orientation.addOrientationListener, I do a lockToPortrait for a small device and do unlockAllOrientations for a large device. If I use addDeviceOrientationListener instead of addOrientationListner, the detection of rotation works even without the line 'registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance());' in the MainApplication.java, but that is not a solution because you cannot lock to portrait.
As said above this works perfectly fine in version 1.1.8 but it does not in 1.2.0. If you need more info, I will gladly provide it.
I have the same problem, addOrientationListener not work at all:
onOrientationChange = orientation => {
console.log('orientation', orientation);
console.log('isLocked', Orientation.isLocked());
if (orientation === 'UNKNOWN') return;
if (orientation === 'PORTRAIT-UPSIDEDOWN') return;
if (orientation === this.state.orientation) return;
console.log(`orientation from ${this.state.orientation} change to ${orientation}`);
this.setState({orientation, isPortrait: !orientation.startsWith('LANDSCAPE')});
};
componentDidMount() {
Orientation.unlockAllOrientations();
Orientation.addOrientationListener(this.onOrientationChange);
}
componentWillUnmount() {
Orientation.lockToPortrait();
Orientation.removeOrientationListener(this.onOrientationChange);
}
#140 fix this issue, but hasn't released yet. You can try master branch to see whether it works. Thanks!