Device

Device

This plugin defines a global device object, which describes the device's hardware and software. Although the object is in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(device.cordova);
}

Properties

Supported platforms

  • Android
  • iOS

device.cordova

Get the version of Cordova running on the device.

var string = device.cordova;

device.platform

Get the device's operating system name.

var string = device.platform;

Quick Example

// Depending on the device, a few examples are:
//   - "Android"
//   - "iOS"
var devicePlatform = device.platform;

device.uuid

Get the device's Universally Unique Identifier (UUID).

var string = device.uuid;

Description

The details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model.

Quick Example

// Android: Returns a random 64-bit integer (as a string, again!)
//          The integer is generated on the device's first boot
//
// iPhone: (Paraphrased from the UIDevice Class documentation)
//         Returns a string of hash values created from multiple hardware identifies.
//         It is guaranteed to be unique for every device and can't be tied
//         to the user account.
var deviceID = device.uuid;

iOS Quirk

The uuid on iOS is not unique to a device, but varies for each application, for each installation. It changes if you delete and re-install the app, and possibly also when you upgrade iOS, or even upgrade the app per version (apparent in iOS 5.1). The uuid is not a reliable value.


device.version

Get the operating system version.

var string = device.version;

Supported Platforms

  • Android 2.1+
  • iOS

Quick Example

// Android:    Froyo OS would return "2.2"
//             Eclair OS would return "2.1", "2.0.1", or "2.0"
//             Version can also return update level "2.1-update1"
//
// iPhone:     iOS 3.2 returns "3.2"
//
var deviceVersion = device.version;