My requirement is to have the app fixed only to portrait mode on phones and only to landscape mode on tabs, starting with the splashscreen. Tried with the Screen Orientation plugin available on ionic native but did not work for me.
Things I have tried:
On app.component.ts:
constructor(..., private screenOrientation: ScreenOrientation) {
platform.ready().then(() => {
this.screenOrientation.lock('landscape');
ScreenOrientation.lockOrientation('landscape');
screen.msLockOrientation('landscape');
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
I have tried all of the above lines on home.ts too but they didn't work. When I set:
console.log(this.screenOrientation.type);
This will print out the screen orientation correctly in logs. Whenever I set the subscribe method, that too works and alerts me whenever the screen orientation changes, which means that all the import statements are working perfectly and that I am able to access the plugin methods correctly. I am able to replicate this issue on both Android and iOS. Any help would be greatly appreciated.
Platform/library/dependency details:
"@angular/common": "4.1.3",
"ionic-angular": "3.6.0",
"ionic": "3.7.0"
In your config.xml
you can try to add this line to make your orientation to lock on landscape mode.
<preference name="orientation" value="landscape" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With