May 21, 2021 Cordova
This plug-in is used to obtain information about the user's device.
To install this plug-in, we need to run the following snippppppy code in the command prompt.
C:\Users\username\Desktop\CordovaProject>cordova plugin add cordova-plugin-device
We will use this plug-in just as we do with other Cordova plug-ins. /b10> Let's add .html the index file. /b11> This button will be used to obtain information for the device.
<button id = "cordovaDevice">CORDOVA DEVICE</button>
The Cordova plug-in is available after the deviceready event, so we'll place the event listener in the onDeviceReady function in index .js.
document.getElementById("cordovaDevice").addEventListener("click", cordovaDevice);
The Cordova plug-in is available after the deviceready event, so we'll place the event listener in the onDeviceReady function in index .js.
function cordovaDevice() { alert("Cordova version: " + device.cordova + "\n" + "Device model: " + device.model + "\n" + "Device platform: " + device.platform + "\n" + "Device UUID: " + device.uuid + "\n" + "Device version: " + device.version); }
When we click the CORDOVA DEVICE button, the alert will display the Cordova version, device model, platform, UUID, and device version.