cordova device plugin
cordova device plugin
cordova device plugin

In previous tutorials, we had look on phonegap events, this lesson we’re going learn how to use cordova device plugin. In this phonegap device api tutorial,i will explain how to get device information such as device uuid, model, platform, version. cordova version using Phonegap / Apache Cordova device plugin.

What you’ll learn from this tutorial ?

  • What is device api?
  • How to get device information using phonegap device api ?
  • how to create phonegap application for getting device information ?

What is device api ?

Device api is used to gather specific information about device such as cordova version, mobile model , platform information, device unique id (UUID). OS version

What are the properties of phonegap device api?

  • device.cordova returns cordova version
  • device.model returns device model (E.g HTC 132)
  • device.platform platform information (E.g Android)
  • device.uuid returns phone unique id (1sd341sdr1)
  • device.version App version

How to get device information using phonegap device api ?

Create Phonegap / Apache Cordova project

cordova create DeviceInfo com.phongap.deviceinfo DeviceInfo

Change working directory

cd DeviceInfo

Add Platform

cordova platform add android

Now add plugin for device plugin

cordova plugin add cordova-plugin-device

Now Change your index.html code

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Device Info</title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
 document.addEventListener("deviceready", function(){
  var deviceinfo = "cordova:"+device.cordova+"<br>Model:"+device.model+"<br>UUID:"+device.uuid+"<br>Platform:"+device.platform+"("+device.version+")";
  document.getElementById("deviceInfoText").innerHTML = deviceinfo;
<p id="deviceInfoText"></p>
Sundaravel M

About the author: Hey! It's me sundar. (Yea, I'm the founder of I'm a passionate computer programmer who loves modern web and mobile development. feel free to reach me : Facebook - Twitter - Google+