id_cap_identiy_device缺少WP8.1功能
-
20-12-2019 - |
题
为什么WP8.1中缺少能力id_cap_identity_device? 由于此,我无法让设备ID匹配我在WP8中获得的那个!
又导致应用程序升级中的许多问题!
现在我正在使用,
HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null);
IBuffer hardwareId = token.Id;
HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm("MD5");
IBuffer hashed = hasher.HashData(hardwareId);
string DeviceId = CryptographicBuffer.EncodeToHexString(hashed);
return DeviceId ;
.
以前我们使用过,
DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId);
result = (byte[])uniqueId;
string id = Convert.ToBase64String(result).Replace("=", "").Replace("/", "").Replace("+", "");
return id + "";
.
请建议解决方案,以便我们可以在两个平台上获得类似的ID!
所有帮助和建议都赞赏。
解决方案
如果您正在开发Windows Phone 8.1 XAML应用程序,它不会支持id_cap_identity_device,因为它可以部署在任何设备上,即电话,平板电脑或桌面。因此,您可以使用WardionIndentification类来获取设备ID
private string GetDeviceID()
{
HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null);
IBuffer hardwareId = token.Id;
HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm("MD5");
IBuffer hashed = hasher.HashData(hardwareId);
string hashedString = CryptographicBuffer.EncodeToHexString(hashed);
return hashedString;
}
.
不隶属于 StackOverflow