Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device ID in a UWP app (threshold 1)

In Phone 8.1 you could get the device ID using HardwareIdentification, and even though the documentation says it exists for Desktop apps, it does not exist for a UWP app.

Screenshot of hardware profile not existing

What is the alternative or a way to get a hardware ID for a UWP?

like image 691
Robert MacLean Avatar asked Sep 01 '15 11:09

Robert MacLean


1 Answers

You're running into a common issue when migrating an app from Windows (Phone) 8(.1) to the Windows Universal Platform.

The reason you're not seeing the HardwareIdentification is pretty simple: You don't reference the required sources!

You only see AnalyticsInfo and AnalyticsVersionInfo. This is because they are part of the Universal Device Family, as stated on the documentation page (https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.analyticsinfo.aspx) at the very bottom.

The HardwareIdentification however is not part of the Universal Device Family, it's part of the Desktop and Mobile family, as Adriano alread stated in his comment.

To make the info available, you have to add the references to the specific extensions: enter image description here

After that, make sure to check if the type exists, before calling it:

if (Windows.Foundation.Metadata.ApiInformation
    .IsTypePresent("Windows.System.Profile.HardwareIdentification"))
like image 169
Herdo Avatar answered Sep 19 '22 22:09

Herdo