Hello Readers,
Today's post is about Cordova device plugin that describes the device's hardware and software.
We need to install cordova device plugin via CLI:
$ cordova plugin add cordova-plugin-device
This plugin defines a global object device which is works in deviceready function.
This plugin has following properties :
- device.cordova : We can get Cordova version running on our device.
Example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device.cordova);
}
- device.model : Get the device model or product information which is set by manufacturer. Model and product information can be change of two same devices.
Example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device.model);
}
- device.platform : We can get the operating system on which application is running ex: iOS, Android and Windows etc.
Example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device.platform);
}
- device.uuid : We can get the universal unique device identifier.
Example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device.uuid);
}
- device.version : Get the device's operating system version.
Example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device.version);
}
- device.manufacturer : Get the device manufacturer's name.
Example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device.manufacturer);
}
- device.isVirtual : Get the information is application running on device or simulator if running on simulator it gives true otherwise false.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device.isVirtual);
}
- device.serial : Serial number of device provided by manufacturer.
Example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device.serial);
}
Hope this will help you : )
0 Comment(s)