App rotations

There are several cases where rotations come into play with your app. You might want to limit your app to a single rotation, or allow all of them. Alternatively, you might want to have e.g. a landscape-only modal slide on top of your app that is otherwise always in portrait mode.

Setting allowed rotations via the Build Service

iOS and Android really want rotations to be the same app-wide, and they're defined during the build phase. Thus, the way to set rotations is in the Build Service, on your app's Build Configuration page. The defaults will apply for all views in your app. (Note that a custom-built Scanner app will also have the same default rotations, which is useful for testing and development.)

iOS

iOS Rotation Settings

Check all the orientations that apply, separately for iPhone and iPad.

Android

Android Rotation Settings

Select the orientation you want to use. See the official documentation for an explanation of the values.

Setting allowed rotations via JavaScript

The supersonic.ui.screen.setAllowedRotations API call allows you to override the default allowed device orientations, affecting all app views. The exception is modals, for which you have to set the rotations separately.


API Reference: supersonic.ui.screen.setAllowedRotations()

Determine which of the four possible screen rotations are enabled on your device. By default all rotations are allowed, with the exception of custom builds where the build settings have been used to lock the app into a certain rotation scheme. Modals are not affected by setting allowed rotations in other views and conversely setting allowed rotations in a modal does not affect the rest of the app.

Note: This method is not available on Android due to OS limitations on rotations.

Example usage

supersonic.ui.screen.setAllowedRotations(["landscapeLeft", "landscapeRight"]);
supersonic.ui.screen.setAllowedRotations ["landscapeLeft", "landscapeRight"]

Parameters

setAllowedRotations : (
  orientations: Array<String>
) => Promise
Name Type Default Details
rotations Array<String>

Allowed rotations. Possible values are "portrait", "portraitUpsideDown", "landscapeLeft" and "landscapeRight".

Returns

Returns a Promise that is resolved when the allowed rotations are set.

Also supports callbacks.