Skip to main content
Version: v6

Screen Orientation

Cordova plugin to set/lock the screen orientation in a common way.

Requires Cordova plugin: cordova-plugin-screen-orientation. For more info, please see the Screen Orientation plugin docs.

https://github.com/apache/cordova-plugin-screen-orientation

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation

$ npm install cordova-plugin-screen-orientation 
$ npm install @awesome-cordova-plugins/screen-orientation
$ ionic cap sync

Supported Platforms

  • Android
  • iOS
  • Windows

Usage

React

Learn more about using Ionic Native components in React

Angular

import { ScreenOrientation } from '@awesome-cordova-plugins/screen-orientation/ngx';

constructor(private screenOrientation: ScreenOrientation) { }

...


// get current
console.log(this.screenOrientation.type); // logs the current orientation, example: 'landscape'

// set to landscape
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);

// allow user rotate
this.screenOrientation.unlock();

// detect orientation changes
this.screenOrientation.onChange().subscribe(
() => {
console.log("Orientation Changed");
}
);