react-native-orientation-locker icon indicating copy to clipboard operation
react-native-orientation-locker copied to clipboard

[IOS] addDeviceOrientationListener not working on IOS device when Auto-rotate turn off

Open dinhtrumdieu opened this issue 3 years ago • 9 comments

I want to listen to orientation changes when the AUTO rotate turn off. The fact that I wasn't getting addDeviceOrientationListener on IOS even when it was working on Android

RN: 0.61.5

dinhtrumdieu avatar Sep 14 '20 09:09 dinhtrumdieu

+1, Is there a solution?

liran avatar Nov 16 '20 19:11 liran

+1

psamd avatar Jun 09 '21 09:06 psamd

Any update on this? I have it working on Android but the same code doesn't work on IOS (Testing on an Iphone 11).

For anyone interested. If you use Orientation.lockToPortrait() to lock into portrait mode instead of using the phone's rotation lock menu setting, then it works.

Cannonball2134 avatar Jun 25 '21 13:06 Cannonball2134

Having the same exact issue...

jzxchiang1 avatar Dec 05 '21 23:12 jzxchiang1

Resolved it by patching this on my local react-native-orientation-locker package:

https://gist.github.com/jzxchiang1/bd7e906038eb9a2c57857b5f1a0d6a3f

Use npx patch-package to do that. Make sure to rebuild your app's native code after doing this using typical npm run ios or Xcode run.

Code copied from react-native-camera, which implements this correctly: https://github.com/react-native-camera/react-native-camera/blob/941536592cb8ad6f65f3cb50e2fe814b7c70c093/ios/RCT/RCTSensorOrientationChecker.m

Hope this helps!

jzxchiang1 avatar Dec 06 '21 02:12 jzxchiang1

Unfortunately I'm using react-native-orientation-locker 1.6, and after running "npx patch-package" and "npm run ios" it still doesn't work even though the above process doesn't error.

chungvqvinorsoft avatar Jan 11 '24 09:01 chungvqvinorsoft

I have the same problem, auto rotate works on android but not on ios, any solution?

eliasg52 avatar Jan 17 '24 12:01 eliasg52

Not fixed in 1.7.0

CyxouD avatar May 01 '24 13:05 CyxouD

@jzxchiang1 It doesn't work in my case (I use 1.5 version, but it shouldn't matter)

CyxouD avatar May 01 '24 13:05 CyxouD