I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
Screen Orientation is not locked on iOS 12.x
XCode console shows
鈿★笍 [log] - Current screen orientation portrait-primary
To Native Cordova -> CDVOrientation screenOrientation INVALID ["options": [3, portrait]]
Expected behavior:
Must lock the orientation
Steps to reproduce:
Related code:
In my component I invoke
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT);
Please note that i use capacitor to support native features. The same code works fine in ionic 3.9.2 with cordova (no error and screen orientation is locked)
Other information:
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
alexs-mbp:bossdesk.mobile2 alexryltsov$ ionic info
Ionic:
ionic (Ionic CLI) : 4.5.0 (/Users/alexryltsov/.nvm/versions/node/v10.14.2/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.17
@angular-devkit/build-angular : 0.10.7
@angular-devkit/schematics : 7.0.7
@angular/cli : 7.0.7
@ionic/angular-toolkit : 1.2.0
Capacitor:
capacitor (Capacitor CLI) : 1.0.0-beta.11
@capacitor/core : 1.0.0-beta.11
Cordova:
cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (1 plugins total)
System:
Android SDK Tools : 26.1.1 (/Users/alexryltsov/Library/Android/sdk/)
NodeJS : v10.14.2 (/Users/alexryltsov/.nvm/versions/node/v10.14.2/bin/node)
npm : 6.5.0
OS : macOS Mojave
Xcode : Xcode 10.1 Build version 10B61
alexs-mbp:bossdesk.mobile2 alexryltsov$
It seems that inside CDVOrientation.m one of the methods returns an error "Error calling to set supported orientations"
When will this fix be available?
Should be on beta 12, was released on Friday
I am having this issue as well. Is this fixed?
I am still having this issue in ionic 4 using capacitor. works perfectly fine in IPhone but not working on IPad. Appreciate your help @mlynch @jcesarmobile
Just found out that this error is back again event though the screen orientation lock seems to be working
To Native Cordova -> CDVOrientation screenOrientation INVALID ["options": [3, portrait]]
Here is my current environment
ionic info
Ionic:
Ionic CLI : 6.2.1 (/Users/alexryltsov/.nvm/versions/node/v12.16.1/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.0.5
@angular-devkit/build-angular : 0.803.23
@angular-devkit/schematics : 8.3.25
@angular/cli : 8.3.25
@ionic/angular-toolkit : 2.2.0
Capacitor:
Capacitor CLI : 2.0.0-beta.1
@capacitor/core : 2.0.0-beta.1
Cordova:
Cordova CLI : not installed
Cordova Platforms : not available
Cordova Plugins : not available
Utility:
cordova-res : not installed
native-run : not installed
System:
Android SDK Tools : 26.1.1 (/Users/alexryltsov/Library/Android/sdk/)
NodeJS : v12.16.1 (/Users/alexryltsov/.nvm/versions/node/v12.16.1/bin/node)
npm : 6.13.4
OS : macOS Catalina
Xcode : Xcode 11.4 Build version 11E146
I can confirm @ryaa's comment - I'm also seeing this error now with Capacitor 2.0 (and 2.1).
Even though the screen orientation lock works, the keyboard orientation lock doesn't which results in the following state when rotating:

I am also having this issue with Capacitor 2.1 and iOS.
Also in XCode only Portrait and Upside-Down is activated but it is still switching to Landscape.
@pentabarf this was fixed in https://github.com/ionic-team/capacitor/pull/2995 and released in https://github.com/ionic-team/capacitor/releases/tag/2.1.1
Most helpful comment
I am still having this issue in ionic 4 using capacitor. works perfectly fine in IPhone but not working on IPad. Appreciate your help @mlynch @jcesarmobile