Device Unique id in Windows Phone 8.1

前端 未结 2 912
情话喂你
情话喂你 2020-12-05 04:59

How to get the device unique id in Windows Phone 8.1? The old way of using DeviceExtendedProperties.GetValue(\"DeviceUniqueId\") does not work for Windows Unive

相关标签:
2条回答
  • 2020-12-05 05:26

    Note that when you write Universal App, it can be installed not only on phone. While on Phone technically hardware configuration is the same, on other devices it can change and so its ID. That's I think there is no such universal method to get ID. (more information you can find also here).

    You may have a look at HardwareIdentification class and its method GetPackageSpecificToken:

    HardwareToken myToken = HardwareIdentification.GetPackageSpecificToken(null);
    IBuffer hardwareId = myToken.Id;
    

    There is also a Guidance on using the App Specific Hardware ID (ASHWID) to implement per-device app logic.

    0 讨论(0)
  • 2020-12-05 05:30
    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;
    }
    

    Hope this help !

    0 讨论(0)
提交回复
热议问题