How to get a device identifier using Phonegap

Agustín picture Agustín · Dec 3, 2013 · Viewed 28k times · Source

I need to get any number, serial, key or whatever to identify every device where my phonegap app is running, I think uuid also changes when the app updates so it wouldn't work for me.

The scenario here is that the user can synchronize data from the app, so I need to know which device has synchronized and which has not, or if it needs to update new data that maybe others devices have already done, etc

any ideas?

Answer

Purus picture Purus · Dec 3, 2013
<script type="text/javascript" charset="utf-8">

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    var element = document.getElementById('deviceProperties');
    element.innerHTML = 'Device Model: '    + device.model    + '<br />' +
                        'Device Cordova: '  + device.cordova  + '<br />' +
                        'Device Platform: ' + device.platform + '<br />' +
                        'Device UUID: '     + device.uuid     + '<br />' +
                        'Device Version: '  + device.version  + '<br />';
}

</script>

After getting the device info you can apply your logic to validation.

Refer: http://docs.phonegap.com/en/3.2.0/cordova_device_device.md.html#Device