Screen Orientation does not work

I have followed these guidelines.

The orientation lock for portrait works in emulator. When I rotate the device in emulator it fixes to portrait orientation but it DOES not work in devices; Iphone 11 pro max, iphone 11 pro, and tested with samsung android. There is no error showing in console. I can even see the console.log: portrait-primary.

Why I cant get it work with devices after going through appflow? Need help please.

in app.module.ts:
import { ScreenOrientation } from ‘@ionic-native/screen-orientation’;

providers: [ScreenOrientation]

in app.component.ts
import { ScreenOrientation } from ‘@ionic-native/screen-orientation’;


as a result no error. it only works in emulator and I can see console.log: portrait-primary which is correct orientation detected. But not working in devices.

Rotated in emulator:

I wanted to add these from package.json

“dependencies”: {
@angular/animations”: “5.2.11”,
@angular/common”: “5.2.11”,
@angular/compiler”: “5.2.11”,
@angular/compiler-cli”: “5.2.11”,
@angular/core”: “5.2.11”,
@angular/forms”: “5.2.11”,
@angular/http”: “5.2.11”,
@angular/platform-browser”: “5.2.11”,
@angular/platform-browser-dynamic”: “5.2.11”,
@capacitor/android”: “^1.4.0”,
@capacitor/core”: “1.4.0”,
@ionic-native/browser-tab”: “^4.16.0”,
@ionic-native/camera”: “^4.16.0”,
@ionic-native/card-io”: “^4.20.0”,
@ionic-native/core”: “^4.15.0”,
@ionic-native/file-transfer”: “^4.16.0”,
@ionic-native/geolocation”: “^4.15.0”,
@ionic-native/http”: “^4.16.0”,
@ionic-native/in-app-browser”: “^4.16.0”,
@ionic-native/native-geocoder”: “^4.20.0”,
@ionic-native/screen-orientation”: “^4.20.0”,
@ionic-native/sms”: “^4.16.0”,
@ionic-native/splash-screen”: “~4.15.0”,
@ionic-native/status-bar”: “~4.15.0”,
@ionic-native/stripe”: “^4.16.0”,
@ionic/pro”: “^2.0.4”,
@ionic/storage”: “2.2.0”,
@types/google-maps”: “^3.2.1”,
“”: “^2.1.0”,
“cordova-android”: “7.1.4”,
“cordova-ios”: “5.0.1”,
“cordova-plugin-add-swift-support”: “^2.0.2”,

As I have mentioned I dont have dependencies version match or any other error.

Hi, have you tried with?

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