Cordova - Device




Cordova - Device

This plugin is used for getting information about the user’s device.

Step 1 - Installing Device Plugin

To install this plugin, we need to run the following snippet in the command prompt.

C:\Users\username\Desktop\CordovaProject>cordova plugin add cordova-plugin-device

Step 2 - Adding Button

We will be using this plugin the same way we used the other Cordova plugins. Let us add a button in the index.html file. This button will be used for getting information about the device.

<button id = "cordovaDevice">CORDOVA DEVICE</button>

Step 3 - Adding Event Listener

Cordova plugins are available after the deviceready event so we will place the event listener inside the onDeviceReady function in index.js.

document.getElementById("cordovaDevice").addEventListener("click", cordovaDevice);	

Step 4 - Creating Function

The following function will show how to use all possibilities the plugin provides. We will place it 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.

Cordova - Device



Frequently Asked Questions

+
Ans: Cordova - Contacts view more..
+
Ans: Cordova - Camera view more..
+
Ans: Cordova - Battery Status view more..
+
Ans: Cordova - Device view more..
+
Ans: Cordova - Accelerometer view more..
+
Ans: Cordova - Device Orientation view more..
+
Ans: Cordova - Dialogs view more..
+
Ans: Cordova - File System view more..
+
Ans: Cordova - File Transfer view more..
+
Ans: Cordova - Geolocation view more..
+
Ans: Cordova - Globalization view more..
+
Ans: Cordova - InAppBrowser view more..
+
Ans: Cordova - Media view more..
+
Ans: Cordova - Media Capture view more..
+
Ans: Cordova - Network Information view more..
+
Ans: Cordova - Splash Screen view more..
+
Ans: Cordova - Vibration view more..
+
Ans: Cordova - Whitelist view more..




Rating - NAN/5
504 views

Advertisements