Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen orientation lock is not working in ionic

I'm building an app using [email protected], and I'm trying to control my screen orientation for each screen. I'm using the plugin [email protected].

and I use the following code to change the orientation

  screen.orientation.unlock();
  screen.orientation.lock('portrait');

However my screen orientation doesn't change. I'm getting this error when inspecting the code.

Uncaught (in promise) DOMException: screen.orientation.lock() is not available on this device.

Please help.

like image 490
Mahesh Eu Avatar asked Mar 12 '26 11:03

Mahesh Eu


1 Answers

The problem is not with any plugin. The reason for this not working is that Cordova doesn't run with the command ionic serve. So it'll not work in the inspect tab. Use an emulator instead, it'll work just fine.

like image 195
Vedant Avatar answered Mar 15 '26 01:03

Vedant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!