ScreenOrientation problems

Hi,
I can’t make to work a @ionic-native/screen-orientation/ngx

@ionic-native/screen-orientation”: “^5.23.0”,

module.ts:

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

  providers: [
    EventHandlerService,
    FabricShapeService,
    ScreenOrientation
  ]

AppComponent.ts:

export class AppComponent {
  constructor(
    private platform: Platform,
    private splashScreen: SplashScreen,
    private statusBar: StatusBar,
    private screenOrientation: ScreenOrientation
  ) {

I got this error:

AppComponent -> ScreenOrientation]: NullInjectorError: No provider for ScreenOrientation!

Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 5 other plugins)

thanks in advanced

Two Question::

  1. Which Ionic Version do you use?
  2. For what do you want to use Screen Orientation?

hi,
thank’s for reply

ionic -v
5.4.16

the application must be used in landscape

Remove the Plugin and use:


<preference name="Orientation" value="landscape" />

https://cordova.apache.org/docs/en/3.1.0/config_ref/index.html#global-preferences

hi,
thanks for reply
I had not thought of such a solution, I will try it

Your iPhone is in portrait mode when you hold it upright. It is in landscape mode when it is on its side. If the display orientation does not change when holding your iPhone in either ways, then it can be an indication that screen orientation is not working on your device official website

hi, thank’s for reply

I don’t know if it’s my case
the problem is present in the simultaore which is enabled for rotation

is seems a plugin bug