Kinjan Bhavsar
Kinjan Bhavsar

Reputation: 1449

Unique ID in UWP?

I need to send a unique ID of the device to the server for some requirements at the server. So after some research, I used the following

new EasClientDeviceInformation().Id.ToString();

But, during testing, I found that it is giving the same value for the emulator and my Lumia device.

Also, I got 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 user's group. Each component of the GUID is returned in network byte order.

Does EasClientDeviceInformation don't give unique id?

Upvotes: 3

Views: 2905

Answers (1)

Igor Damiani
Igor Damiani

Reputation: 1927

You need to add a reference to "Windows Desktop Extensions for the UWP" assembly and then:

var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;

See this articles:

Device ID in a UWP app (threshold 1)

How do I get a Unique Identifier for a Device within Windows 10 Universal?

Upvotes: 3

Related Questions