DedrisFrameworkDedrisFramework

← Plugins  /  Device

📲

Device

cordova-plugin-device
iOS Android 🌐 Browser

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.

Installation

Add the plugin to your Cordova project from the command line:

terminal
cordova plugin add cordova-plugin-device

Properties

The plugin fills in the global device object. Its values are only available after the deviceready event has fired:

PropertyTypeDescription
device.cordovaStringVersion of Cordova running on the device.
device.modelStringProduction model name, for example iPhone15,2.
device.platformStringOperating-system name, such as iOS or Android.
device.uuidStringIdentifier for the device.
device.versionStringOperating-system version.
device.manufacturerStringName of the device's manufacturer.
device.isVirtualBooleanWhether the app is running on a simulator or emulator.
device.serialStringHardware serial number (Android).

Usage example

Read a few device properties once the app is ready:

www/js/app.js
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.

Tips

📚 Source: the technical reference on this page (the properties and the install command) is based on the official Apache Cordova device documentation. Descriptions and examples have been rewritten in DedrisFramework's own words. Apache Cordova documentation is published by the Apache Software Foundation under the Apache License 2.0.
← Back to plugins Start a project