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.
What is the alternative or a way to get a hardware ID for a UWP?
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:
After that, make sure to check if the type exists, before calling it:
if (Windows.Foundation.Metadata.ApiInformation
.IsTypePresent("Windows.System.Profile.HardwareIdentification"))
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