This is my old implementation to get a Unique DeviceID for Windows Universal 8.1 but the type HardwareIdentification does not exist anymore.
private static string GetId()
{
var token = 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("-", "");
}
Each device in Windows has it's own unique identifier known as the Hardware ID. The Device ID is the identifier of the PC itself.
A unique identifier (UID) is a numeric or alphanumeric string that is associated with a single entity within a given system. UIDs make it possible to address that entity, so that it can be accessed and interacted with.
It seems that
var deviceInformation = new EasClientDeviceInformation();
string Id = deviceInformation.Id.ToString();
is doing the magic, refering to EasClientDeviceInformation it provides a unique Id.
The Id property represents the DeviceId using the GUID truncated from the first 16 bytes of the SHA256 hash of the MachineID, User SID, and Package Family Name where the MachineID uses the SID of the local users group.
BUT it only works for Windows Store Apps... so there have to be another solution.
See this Q&A for a much better way to get an ID.
You need to add a reference to the Desktop and / or Mobile SDKs to build against the Hardware Token. At runtime you should use the ApiInformation
type to query if the API is present before using it (other device families like Xbox don't have it).
That said, many times when people ask for the device ID that's not actually the best solution for their problem -- are you sure you need to identify the physical device across its entire lifespan, even if ownership changes?
EasClientDeviceInformation does not work for Windows 10 mobile. The device id is just the same for every phone (all our win10m customers gets registered with the same GUID) We need the id for sending push messages to the right phone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With