question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

screen orientation lock does not work on iOS 12.x (ionic 4 with capacitor)

See original GitHub issue

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 (cordova-lib@8.1.1)
   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$

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
ryaacommented, Apr 2, 2020

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
3reactions
Kudla161992commented, Mar 11, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic 4 application - screen orientation lock not working
I am trying to fix screen orientation to portrait for one page in my ionic 4 application. ... logging the current orientation and...
Read more >
Ionic Screen Orientation Cordova Plugin is not locking to ...
First you will need to use Cordova net.yoik.cordova.plugins.screenorientation plugin. You can easily programmatically lock/unlock screen ...
Read more >
Handling Screen Orientation Changes in Capacitor Apps
This tutorial discusses how to handle screen orientation changes on capacitor based Android and iOS apps. Fundamentals of an Ionic App.
Read more >
Screen Orientation | Capacitor Documentation
iOS allows for different screen orientations to be supported on iPhones and iPads. To limit the allowed orientations for iOS, open Xcode and...
Read more >
Change or lock the screen orientation on iPad - Apple Support
You can lock the screen orientation so that it doesn't change when you rotate iPad. Open Control Center, then tap the Lock Orientation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found