ScreenOrientation native doesn't work


#1

I want to lock one of my page in landscape mode. i just try with ionic native https://ionicframework.com/docs/v2/native/screen-orientation/ but it doesn’t work it still with vertical view how can i make for particular page in landscape view. any idea?


#2

Hi,
I have the same problem, I get this error:
> EXCEPTION: Uncaught (in promise): SecurityError: The page needs to be fullscreen in order to call screen.orientation.lock().
Anyone?


#3

Your error message suggests setting the fullscreen preference to true in config.xml.


#4
this code works for me just give a try

import { ScreenOrientation } from '@ionic-native/screen-orientation';

constructor(private screenOrientation: ScreenOrientation) {}

ionViewDidLoad() {
    this.screenOrientation.lock('landscape');
}

#5

Thanks for your answers.

I have the same code and I tried with the fullscreen option in config.xml

I have @ionic-native/screen-orientation version 3.6.1, ionic version 2.2.3, cordova version 6.5.0 and cordova-plugin-screen-orientation version 1.4.2

Still no luck


#6

Updating cordova-plugin-screen-orientation to version 2.0.1 solved my issue.