Bug Report: Orientation


Compiling an app with “Portrait” orientation:

  • App runs in portrait mode. No problem here.

Compiling an app with “Landscape” orientation:

  • App runs in landscape mode. No problem here.

Compiling an app with “Both” orientations:

  • App runs in portrait mode only (rotating device does not switch to landscape).

Furthermore, documentation suggests that the following commands should allow us to set the orientation:

  • Cocoon.Device.setOrientation(Cocoon.Device.Orientations.PORTRAIT);
  • Cocoon.Device.setOrientation(Cocoon.Device.Orientations.LANDSCAPE);
  • Cocoon.Device.setOrientation(Cocoon.Device.Orientations.BOTH);

However, the commands seem to have no effect when called. (For example, setting to “Landscape” orientation while running a “Portrait” app does nothing.)

The above tests were:

  • Canvas+ apps compiled with Cocoon 1.3.0
  • run on an iPhone 5S running iOS 9.1


I did some further testing.

I compiled a Developer app and in the “settings” while running the app, I set the orientation to each of “Landscape”, “Portrait”, and “Both”. For each mode, I loaded/ran my app and ran the command console.log(Cocoon.Device.getOrientation());.

Portrait mode logged 1
Landscape mode logged 8
Both mode logged 9

I then ran again with Landscape mode, and ran the two commands:


As expected, the orientation mode “changed” to portrait and a 1 was logged.

However, the app continued to actually run in landscape mode.


We will look into this issue. Thanks for pointing it out.

Would you mind to perform a test on Android just to verify if it is an iOS specific issue? We will too ;).



Some further testing, as requested:

Unlike on iOS (which which got stuck in portrait mode), the “Both” orientation setting works fine on Android. You can rotate the device and the orientation will adjust automatically.

Again unlike on iOS, on Android the following commands can be executed and the orientation will change:

  • Cocoon.Device.setOrientation(Cocoon.Device.Orientations.PORTRAIT);
  • Cocoon.Device.setOrientation(Cocoon.Device.Orientations.LANDSCAPE);

However, just like on iOS, the above commands don’t work when executed from within a Dev App. They do change the return value of Cocoon.Device.getOrientation(), however the orientation doesn’t actually change.


Are there any plans to fix this bug in a near update? As it stands, switching between PORTRAIT and LANDSCAPE at will is not possible on iOS.


Can you try this? https://github.com/gbenvenuti/cordova-plugin-screen-orientation

We don’t have plans to work on this bug in a near updates because this is a legacy utility that’s only available in Canvas+ and we would like to do it in a more cordova standard way or create a new specific utilities plugin.


If I use release 1.4.0 of that plugin, my app won’t compile on iOS. A dump of the failed build can be found here. Specifically though, the problem seems to be this:

fatal error: ‘Cordova/CDVShared.h’ file not found

This solution on StackOverflow says to do the following:

For xcode7 add "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" to your Header Search Paths (and you may need to set Enable Bitcode to No - was necessary for me, but may be related to different problem with xc7)

Sadly this sounds like something that would need to be done on the Cocoon side.

I don’t suppose it would be possible to do something like this via the project config.xml file?

Edit 1:

Looks like there’s an issue being tracked already that mentions this:


Edit 2:

It seems that Apache has plans to implement a core plugin that would replace this broken plugin:



Are there any plans to fix this bug?

The official version of that plugin (https://github.com/apache/cordova-plugin-screen-orientation) doesn’t seem to be doing anything.


Can you provide more detail? What do you mean it doesn’t seem to be doing anything? How do you know? What steps did you take to try to get things working?


@Joncom have you gotten it to work?
I installed the plugin from config.xml and compiled a new devapp. I set the orientation to both and tried rotating the device, but the screen stayed the same again.
Using the functions screen.lockOrientation(‘portrait’) and ‘landscape’ didn’t seem to rotate the screen either, but it did change the value for screen.orientation


@LuckyK No I did not try that new repo yet. Sorry. However you could try pointing your config.xml to load the plugin directly from the Git repo instead of selecting whatever is available in the Cocoon plugins list (because that can sometimes be out-dated).


@LuckyK @Joncom So as far as I understand this is only happening in the Developer App, is that correct?


Actually I hadn’t tried this before outside the Developer App, but the normal app does indeed rotate!
In that case I might be able to work with this. I will look more in to it.


OK, we are taking a look at it.