title: Device
description: Get device information.
Android 4.4 | Android 5.1 | Android 6.0 | iOS 9.3 | iOS 10.0 | Windows 10 Store | Travis CI |
---|
| | | | | | |
cordova-plugin-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);
}
Report issues with this plugin on the Apache Cordova issue tracker
Installation
cordova plugin add cordova-plugin-device
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
- Amazon Fire OS
- Android
- BlackBerry 10
- Browser
- Firefox OS
- iOS
- Tizen
- Windows Phone 7 and 8
- Windows
- OSX
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
- BlackBerry 10
- Browser
- iOS
- Tizen
- Windows Phone 7 and 8
- Windows
- OSX
Quick Example
var model = device.model;
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
.
Tizen Quirks
- Returns the device model assigned by the vendor, for example,
TIZEN
Windows Phone 7 and 8 Quirks
- Returns the device model specified by the manufacturer. For example, the Samsung Focus returns
SGH-i917
.
device.platform
Get the device's operating system name.
var string = device.platform;
Supported Platforms
- Android
- BlackBerry 10
- Browser
- Firefox OS
- iOS
- Tizen
- Windows Phone 7 and 8
- Windows
- OSX
Quick Example
var devicePlatform = device.platform;
Windows Phone 7 Quirks
Windows Phone 7 devices report the platform as WinCE
.
Windows Phone 8 Quirks
Windows Phone 8 devices report the platform as Win32NT
.
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.
Supported Platforms
- Android
- BlackBerry 10
- iOS
- Tizen
- Windows Phone 7 and 8
- Windows
- OSX
Quick Example
var deviceID = device.uuid;
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.
OSX Quirk
The uuid
on OSX is generated automatically if it does not exist yet and is stored in the standardUserDefaults
in the CDVUUID
property.
Windows Phone 7 and 8 Quirks
The uuid
for Windows Phone 7 requires the permission
ID_CAP_IDENTITY_DEVICE
. Microsoft will likely deprecate this
property soon. If the capability is not available, the application
generates a persistent guid that is maintained for the duration of the
application's installation on the device.
device.version
Get the operating system version.
var string = device.version;
Supported Platforms
- Android 2.1+
- BlackBerry 10
- Browser
- iOS
- Tizen
- Windows Phone 7 and 8
- Windows
- OSX
Quick Example
var deviceVersion = device.version;
device.manufacturer
Get the device's manufacturer.
var string = device.manufacturer;
Supported Platforms
- Android
- BlackBerry 10
- iOS
- Windows Phone 7 and 8
- Windows
Quick Example
var deviceManufacturer = device.manufacturer;
device.isVirtual
whether the device is running on a simulator.
var isSim = device.isVirtual;
Supported Platforms
- Android 2.1+
- iOS
- Windows Phone 8
- Windows
- OSX
OSX Quirk
The isVirtual
property on OS X always returns false.
device.serial
Get the device hardware serial number (SERIAL).
var string = device.serial;
Supported Platforms