locked
Need to get unique device identifier for each windows device. RRS feed

  • Question

  • Hi

    I am making UWP app where I need to get unique identifier for each device in which my app would be installed. I am using following code -

    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);
                  var  identifier = BitConverter.ToString(bytes);

    This code was working fine from last few months but suddenly client gave us few new devices for testing when we installed our app for all these new devices, saw generated Identifier are same for all devices. These devices have Windows 10 Anniversary update OS. Actually we need to target minimum OS Anniversary update for our app.

    version: 1607 (need to support)

    OS build: 14393.0 (need to support)

    So is there any other way for getting unique identifier for each device? This become serious issue now because time has come to launch this app into market. 


    sandeep chauhan

    Thursday, September 20, 2018 7:46 AM

Answers

  • Hi,

    It's a IBuffer value and you might need to do something to make it readable. It's easy to find it on the internet. Like this:

            var id = systemId.Id;
                    var asHex = Windows.Security.Cryptography.CryptographicBuffer.
                                                          EncodeToHexString(id);
                    var asBase64 = Windows.Security.Cryptography.CryptographicBuffer.
                                                          EncodeToBase64String(id);


    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, September 27, 2018 8:00 AM

All replies

  • Hi,

    There is a way that get a unique Device IDs on Windows 10 Anniversary Update.The Windows 10 Anniversary Update introduced the new SystemIdentification type which does exactly what you want.  You could see this Q&A here:How to get unique Device IDs on Windows 10 Anniversary Update. Please take a look at @Petter's answer.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Azat Tazayan Friday, September 21, 2018 1:19 PM
    Friday, September 21, 2018 5:51 AM
  • Hi Roy

    Thanks for reply.

    I tried to use below code from your reference 

    using Windows.System.Profile;
    
    IBuffer GetSystemId()
    {
      // This sample gets the publisher ID which is the same for all apps
      // by this publisher on this device.
      // Use GetSystemIdForUser if you have the userSystemId capability
      // and need the same ID across all apps for this user (not 
      // really applicable for apps in the Windows Store)
      var systemId = SystemIdentification.GetSystemIdForPublisher();
    
      // Make sure this device can generate the IDs
      if (systemId.Source != SystemIdentificationSource.None)
      {
        // The Id property has a buffer with the unique ID
        return systemId.Id;
      }
    
      // This is a very old PC without the correct hardware. Use 
      // another mechanism to generate an ID (or perhaps just give 
      // up due to the small number of people that won't have the ID; 
      // depends on your business needs).
      return GetIdFromAshwidOrSomethingElse();
    }

    Target version  - Windows 10, version 1803 (10.0; Build 17134)

    minimum version - Windows 10, Anniversary update (10.0; Build 14393)


    sandeep chauhan

    Tuesday, September 25, 2018 1:12 PM
  • Hi,

    It's a IBuffer value and you might need to do something to make it readable. It's easy to find it on the internet. Like this:

            var id = systemId.Id;
                    var asHex = Windows.Security.Cryptography.CryptographicBuffer.
                                                          EncodeToHexString(id);
                    var asBase64 = Windows.Security.Cryptography.CryptographicBuffer.
                                                          EncodeToBase64String(id);


    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, September 27, 2018 8:00 AM