← Plugins / Device
This official Apache Cordova plugin reports basic hardware and operating-system details about
the device your app is running on. It populates a global device object with
properties such as the model, platform and OS version — handy for diagnostics and for tailoring
behaviour to the device.
Add the plugin to your Cordova project from the command line:
cordova plugin add cordova-plugin-device
The plugin fills in the global device object. Its values are only available after the deviceready event has fired:
| Property | Type | Description |
|---|---|---|
device.cordova | String | Version of Cordova running on the device. |
device.model | String | Production model name, for example iPhone15,2. |
device.platform | String | Operating-system name, such as iOS or Android. |
device.uuid | String | Identifier for the device. |
device.version | String | Operating-system version. |
device.manufacturer | String | Name of the device's manufacturer. |
device.isVirtual | Boolean | Whether the app is running on a simulator or emulator. |
device.serial | String | Hardware serial number (Android). |
Read a few device properties once the app is ready:
document.addEventListener("deviceready", onReady, false);
function onReady() {
console.log("Platform: " + device.platform);
console.log("Version: " + device.version);
console.log("Model: " + device.model);
}
The device global is only populated once the deviceready event has fired, so read it from inside that handler.
device.* only after deviceready — the values are empty before then.uuid is not guaranteed to stay the same across reinstalls on every platform.