[英]cordova get device UUID globally
i am using cordova plugin in one of my app,i am need a device UUId,device unique id and i want to use it globally,i am able to get it inside the onDeviceReady() function,but i am unable to use it globally need help. 我在我的一个应用程序中使用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);
To SET item 设置项目
window.localStorage.setItem("uuid", deviceUID);
To GET item value 要获取项目值
window.localStorage.getItem("uuid");
To REMOVE value 去除价值
localStorage.removeItem("uuid");
or even 甚至
localStorage.clear();
Remember you need <script src="cordova.js"></script>
in you index.html 请记住,index.html中需要
<script src="cordova.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.