How to get a device identifier using Phonegap

前端 未结 3 1853
小蘑菇
小蘑菇 2020-12-16 01:51

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

相关标签:
3条回答
  • 2020-12-16 02:07
    <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

    0 讨论(0)
  • 2020-12-16 02:15

    When a user first installs the app you could make an API call to get a unique ID from the system you are using to sync data and then you could store that ID in a localStorage variable, or to a database table. Then you refer to that ID stored on the device when making calls.

    0 讨论(0)
  • 2020-12-16 02:32

    I suggest to use this PhoneGap/Cordova plugin:

    https://github.com/Paldom/UniqueDeviceID

    As declared in the documentation

    it remains the same after app uninstall.

    0 讨论(0)
提交回复
热议问题