Windows Phone 8.1:DeviceExtendedProperties或DeviceStatus for Device Unique ID

Sab*_*eti 2 device unique-id windows-phone-8.1

我想在Windows Phone 8.1中获取设备ID .

DeviceExtendedPropertiesDeviceStatus不是WP8.1可用(没有Microsoft.Phone.Info命名空间).我刚刚找到了EasClientDeviceInformation我无法从中获得的课程Id.酒店有一个例外Id:

在此输入图像描述

其他属性并不是唯一的.

这里有另一个解决方案,但我不知道使用它是否安全或可靠:(?)
/sf/answers/1647604521/

Eld*_*iev 5

是的,你可以使用GetPackageSpecificToken().我已经调查过它并且没有找到任何其他方式.虽然MSDN说该Id属性包含一些硬件信息,但它实际上是任何设备的唯一值,即使是相同的模型.因此,您可以使用它来识别用户的设备.

这就是我在我的应用程序中使用它的方式.随意使用我的代码:

private string GetDeviceId()
{
    var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
    var hardwareId = token.Id;
    var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);

    byte[] bytes = new byte[hardwareId.Length];
    dataReader.ReadBytes(bytes);

    return BitConverter.ToString(bytes).Replace("-", "");
}
Run Code Online (Sandbox Code Playgroud)