Device Plugin

Tested Version: 2.0.3

This document is based on the original Cordova docs available at Cordova Docs.

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);
}

Plugin ID

cordova-plugin-device

Adding the Plugin in Monaca

In order to use this plugin, please enable Device plugin in Monaca Cloud IDE.

Properties

  • device.cordova

  • device.model

  • device.platform

  • device.uuid

  • device.version

  • device.manufacturer

  • device.isVirtual

  • device.serial

device.cordova

Get the version of Cordova running on the device.

Supported Platforms

  • Android

  • iOS

device.model

The device.model returns the name of the device's model or product. The value is set by the device manufacturer and may be different across versions of the same product.

Supported Platforms

  • Android

  • iOS

Quick Example

Android Quirks

  • Gets the product name instead of the model name, which is often the production code name. For example, the Nexus One returns Passion, and Motorola Droid returns voles.

device.platform

Get the device's operating system name.

Supported Platforms

  • Android

  • iOS

Quick Example

device.uuid

Get the device's Universally Unique Identifier (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.

Supported Platforms

  • Android

  • iOS

Quick Example

iOS Quirk

The uuid on iOS uses the identifierForVendor property. It is unique to the device across the same vendor, but will be different for different vendors and will change if all apps from the vendor are deleted and then reinstalled. Refer here for details. The UUID will be the same if app is restored from a backup or iCloud as it is saved in preferences. Users using older versions of this plugin will still receive the same previous UUID generated by another means as it will be retrieved from preferences.

device.version

Get the operating system version.

Supported Platforms

  • Android 2.1+

  • iOS

Quick Example

device.manufacturer

Get the device's manufacturer.

Supported Platforms

  • Android

  • iOS

Quick Example

device.isVirtual

whether the device is running on a simulator.

Supported Platforms

  • Android 2.1+

  • iOS

device.serial

Get the device hardware serial number (SERIAL).

Supported Platforms

  • Android

See Also:

Last updated

Was this helpful?