使用Javascript [duplicate]获取设备的唯一ID

问题描述 投票:3回答:1

这个问题在这里已有答案:

我有一个网站,只能在Chrome浏览器上访问。我想获取设备(主要是android标签)的唯一ID。这个值必须与imei相似。我想使用javascript获取此值。有没有办法使用JavaScript获取设备的唯一ID。

javascript html5 uniqueidentifier
1个回答
0
投票

您可以为此目的访问设备的uuid

你可以使用PhonegapMoSync

在Phonegap中,您可以使用Cordova Device Plugin

  /* Android: Returns a random 64-bit integer (as a string, again!)
      The integer is generated on the device's first boot

   BlackBerry: Returns the PIN number of the device
         This is a nine-digit unique integer (as a string, though!)

   iPhone: (Paraphrased from the UIDevice Class documentation)
     Returns a string of hash values created from multiple hardware identifies.
     It is guaranteed to be unique for every device and can't be tied
     to the user account.
   Windows Phone 7 : Returns a hash of device+current user,
        if the user is not defined, a guid is generated and will persist until the app is uninstalled
   Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
    unique to every GSM and UMTS mobile phone. */

  var deviceID = device.uuid;

在MoSync中,您可以使用Javascript API

<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>

<script type="text/javascript" charset="utf-8" src="js/wormhole.js"></script>
<script type="text/javascript" charset="utf-8">

// Wait for Wormhole to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// Wormhole is ready
//
function onDeviceReady() {
    var element = document.getElementById('deviceProperties');

    element.innerHTML = 'Device Name: '     + device.name     + '<br />' + 
                        'Device Platform: ' + device.platform + '<br />' + 
                        'Device UUID: '     + device.uuid     + '<br />' + 
                        'Device Version: '  + device.version  + '<br />';
}

</script>
</head>
<body>
  <p id="deviceProperties">Loading device properties...</p>
</body>
</html>
© www.soinside.com 2019 - 2024. All rights reserved.