Ionic 2 lockOrientation doesn't work

I am trying to lockOrientation with ionic 2 but no luck with either corodva 5.4.1 nor the latest 6.1.0.

Hey there! Could you share what you’ve tried?

Did you already try to add it as a preference in your config.xml? I have it in one of my apps build with ionic 2 and everything seems to work fine.

I am using the cordova-plugin-screen-orientation plugin and trying to switch between orientations but with no luck, whats your settings on your config file?

Okay, as mhartington said, could you share some code with us? Thanks in advance!

This is the plugin that I am using with ionic 2 beta.3:
cordova-plugin-screen-orientation 1.4.0 "Screen Orientation"

Here is the code:

import {Page, NavController, NavParams} from 'ionic-angular';

/*
  Generated class for the SomePage page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.

*/
@Page({
  templateUrl: 'build/pages/some/some.html',
})

export class SomePage {

//I need to declare this manually otherwise Atom will show me errors.
  private nav:NavController = null;
  private params:NavParams = null;
  private tabBarElement = null;


  static get parameters() {
    return [[NavController], [NavParams]];
  }

  constructor(nav:NavController, params: NavParams, tabBarElement) {
    this.nav = nav;
    this.params = params;
    this.tabBarElement = tabBarElement;
    this.tabBarElement = document.querySelector('#tabs ion-tabbar-section');
  }

  onPageWillEnter() {
    this.tabBarElement.style.display = 'none';// this is the hacky way to  hide the tabs but there's no way to hide the NavBar so please help! I need to hide both!
    window.screen.lockOrientation('landscape'); // this one is not working 
  }

  onPageWillLeave() {
    this.tabBarElement.style.display = 'block';
    window.screen.lockOrientation('portrait');// this one is not working as well
  }
}

Would you mind to share your code with me please? The I cannot change the screen orientation with the plugin.

Anyone get this working? Or is there a better way? I’d like to lock orientation for my app to landscape mode.

i am facing the same problem :frowning: