cordova全球获取设备UUID

时间:2016-08-02 13:11:23

标签: javascript jquery cordova phonegap-plugins

我在我的一个应用程序中使用cordova插件,我需要一个设备UUId,设备唯一ID,我想全局使用它,我能够在onDeviceReady()函数内得到它,但我无法全球使用它需要帮助。

var deviceName
var deviceUID
var deviceOs
var deviceOsVersion
document.addEventListener("deviceready", onDeviceReady, false)
function onDeviceReady() {
deviceName = device.name;
deviceUID = device.uuid;
deviceOs = device.platform;
deviceOsVersion = device.version;
//Use device information as required
// userDetails(deviceUID);
console.log("devicename : " + deviceName + " deviceId: " + deviceUID + " deviceOs: " + deviceOs + " deviceosversion : " + deviceOsVersion);

 }
   //Use device information as required
   // userDetails(deviceUID);
  console.log("devicename : " + deviceName + " deviceId: " + deviceUID + "     deviceOs: " + deviceOs + " deviceosversion : " + deviceOsVersion);

1 个答案:

答案 0 :(得分:0)

设置项目

window.localStorage.setItem("uuid", deviceUID);

获取项目值

window.localStorage.getItem("uuid");

删除值

localStorage.removeItem("uuid");

甚至

localStorage.clear();

请记住,index.html

中需要<script src="cordova.js"></script>