0

I'm working in a Moodle mobile app with Ionic 5 and Cordova, this throw an error on iOS when exit from full screen mode with the rotated device, the UI break up so I'm trying to lock or manage the orientation in full screen mode without success.

I tried with the oficial Ionic plugin (https://ionicframework.com/docs/v5/native/screen-orientation), but when I enter to fullscreen the app can be rotate to landscape freely.

1 Answers1

0

Try window.screen.orientation.lock('portrait' | 'landscape'). I have an app that is always on portrait mode so I lock the screen rotation in the app.component.ts but I'm sure you can also do it at runtime(lock at landscape when in fullscreen and back to unlock or portrait when exit fullscreen.

Josemar Silva
  • 124
  • 1
  • 5
  • Yes, it can work but I need to lock the orientation before the fullscreen close and the event fullscreenchange happens when the closed has been executed. – Aldo Fernando Saia Jul 27 '22 at 18:15
  • I suggest you use this along the Fullscreen trigger(what you use to exit Fullscreen). Create an `eventListener` for the said trigger use `preventDefault`(or `stopPropagation`) and than you lock/unlock orientation and exit Fullscreen programatically – Josemar Silva Jul 28 '22 at 16:06
  • I was trying with your suggestion but didn't work, I guess that the event finished when listener catched it – Aldo Fernando Saia Aug 11 '22 at 17:08