Foundation.Environment

Utilities to inspect and modify the current environment (with regard to environments known to the tool chain).


Implementation Details

Reference paths

  • '/foundation/_digest.ts'
  • '/foundation/core/utilities/_digest.ts'
  • '/foundation/core/utilities/Environment.ts'

Extends

This type does not extend a base type.

Implements

This type does not implement any interfaces.


Example

switch (Foundation.Environment.current()) {
  case Foundation.Environment.NWJS:
    console.log('This is nw.js');
    break;
  case Foundation.Environment.CORDOVA:
    console.log('This is cordova');
    break;
  default:
    console.log('This is a generic web environment');
}

Static Methods

static isCordova(): boolean

  • Returns true if the current environment is detected as being cordova.
  • Internally, this looks for the presence of the top-level cordova object. If the cordova object has not been injected, this test will return false.

static isNwjs(): boolean

  • Returns true if the current environment is detected as being nw.js.
  • Internally, this attempts to require the nw.gui library. If this library cannot be imported, this test will return false.

static current(): string

  • Returns the current environment as one of Environment.NWJS, Environment.CORDOVA, or Environment.WEB

static onMobileDeviceReady(callback: Function): boolean

  • If the environment is Cordova, call the passed callback when the device is ready
  • Returns true if the callback was bound.
  • Available 0.8.0+

static enableMobileImmersiveMode(): boolean

  • Enable immerise mode on Android devices.
  • Returns try if immersive mode was available, otherwise false.
  • Requires Cordova Plugin: cordova-plugin-fullscreen (bundled by default with the tool chain).
  • Available 0.8.0+

static enableMobileKeepAwake(): boolean

  • Enable keep awake funcionality on mobile devices.
  • Returns true if immersive mode was available
  • Requires Cordova Plugin: Insomnia-PhoneGap-Plugin (bundled by default with the tool chain).
  • Available 0.8.0+

static setMobileOrientation(o: string): boolean

  • Set (lock) screen orientation for mobile devices.
  • One of: portrait-primary, portrait-secondary, landscape-primary, landscape-secondary, portrait, landscape, or false to unlock orientation
  • Returns true of orientation changed.
  • Required Cordova Plugin: cordova-plugin-screen-orientation (bundled by default with the tool chain).
  • Available 0.8.0+