cordova device plugin
cordova device plugin
cordova device plugin

Are you thinking about retrieving device information using Cordova (PhoneGap)? You found a solution. I have written a step by step tutorial for using cordova-plugin-device

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 plugin do?
  • How to get device information using PhoneGap device api?
  • how to create PhoneGap application for getting device information?

Why device plugin ?

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

What are the properties of PhoneGap device plugin?

  • 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 plugin?

Create a new Cordova project & change your working directory

cordova create DeviceInfo com.codesundar.deviceinfo DeviceInfo
cd DeviceInfo

cordova platform add android
cordova platform add ios

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">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <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;
        }, false);

        <p id="deviceInfoText"></p>




Sundaravel M

About the author: Hi! I'm Sundaravel (codesundar), Founder of I have been a Web, Mobile App developer, Author, and Teacher since 2014. I also worked as a software consultant for fortune 500 companies. I created to share my real-time knowledge in various technologies such as PhoneGap, Ionic, Flutter and more.