Namespace: Device

Cocoon. Device

All functions related to the device.

Methods

<static> autoLock(enabled)

Enables or disables the auto lock to control if the screen keeps on after an inactivity period. When the auto lock is enabled and the application has no user input for a short period, the system puts the device into a "sleep” state where the screen dims or turns off. When the auto lock is disabled the screen keeps on even when there is no user input for long times.

Parameters:
Name Type Description
enabled Bool

A boolean value that controls whether to enable or disable the auto lock.

Example
Cocoon.Device.autoLock(false);

<static> getDeviceId() → {string}

Returns the device UUID.

Returns:

The device UUID

Type
string
Example
console.log(Cocoon.Device.getDeviceId());

<static> getDeviceInfo() → {Cocoon.Device.DeviceInfo}

Returns the device Info.

Returns:

The device Info

Type
Cocoon.Device.DeviceInfo
Example
console.log( JSON.stringify(Cocoon.Device.getDeviceInfo()) );

<static> getOrientation() → {number}

Retrieves the preferred orientation that has been set in the system.

Returns:

The preferred orientation in the system as a combination of the possible Cocoon.Device.Orientations.

Type
number
Example
console.log(Cocoon.Device.getOrientation());

<static> setOrientation(preferredOrientation)

Sets the preferred orientation in the system.

Parameters:
Name Type Description
preferredOrientation number

The preferred orientation to be set. A combination of the possible Cocoon.Device.Orientations.

Example
Cocoon.Device.setOrientation(Cocoon.Device.Orientations.PORTRAIT);

Members

<static> DeviceInfo

An object that defines the getDeviceInfo returned information.

Properties:
Name Type Description
Cocoon.Device.DeviceInfo object

The object itself

Properties
Name Type Description
os string

The operating system name (ios, android,...).

version string

The operating system version (4.2.2, 5.0,...).

dpi string

The operating system screen density in dpi.

brand string

The device manufacturer (apple, samsung, lg,...).

model string

The device model (iPhone 4S, SAMSUNG-SGH-I997, SAMSUNG-SGH-I997R, etc).

imei string

The phone IMEI.
Android: The phone IMEI is returned or null if the device has not telephony.
iOS: null is returned as we cannot get the IMEI in iOS, no public API available for that yet.

platformId string

The platform Id.

odin string

The Odin generated id: https://code.google.com/p/odinmobile/

openudid string

The OpenUDID generated Id: https://github.com/ylechelle/OpenUDID

<static> Orientations

The predefined possible orientations. There can be a bit level combination of them using the OR operator.

Properties:
Name Type Description
Cocoon.Device.Orientations string

The base object

Properties
Name Type Description
PORTRAIT string

Portrait

PORTRAIT_UPSIDE_DOWN string

Portrait upside-down

LANDSCAPE_LEFT string

Landscape left

LANDSCAPE_RIGHT string

Landscape right

LANDSCAPE string

Landscape

BOTH string

Both

Cocoon Canvas+ - JavaScript Documentation by Ludei, DocStrap Copyright © 2012-2013
The contributors to the JSDoc3 and DocStrap projects.