DeviceOrientationEvent.requestPermission() - how to use in Angular capacitor app?

I’m trying to use this in an Ionic Angular capacitor project, it is needed to get device orientation working in IOS, but it is not accepted by VS Code…

DeviceOrientationEvent.requestPermission()

any

Property ‘requestPermission’ does not exist on type ‘{ new (type: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; prototype: DeviceOrientationEvent; }’.ts(2339)

(DeviceMotionEvent as any).requestPermission()

This gets rid of the error, not sure yet if it works though?

Doesn’t appear to work.

any luck getting this to work?

I recommend using one of the following Capacitor plugins:

  1. @capacitor/screen-orientation
  2. @capawesome/capacitor-screen-orientation

@robingenz, IonicGeoff was asking about the physical device orientation, not the portrait/landscape screen orientation.