locked
Windows store app - Device ID/Unique Id RRS feed

  • Question

  • I have a chatroom  app, and i want to be able to ban users using a unique Id, number , etc..

    Is there a way i can get the device ID of the user's computer/Tablet? If not. Is there any other unique Id i can use on my server to identify certain devices?

    Thursday, September 19, 2013 11:19 AM

Answers

  • I have a chatroom  app, and i want to be able to ban users using a unique Id, number , etc..

    Is there a way i can get the device ID of the user's computer/Tablet? If not. Is there any other unique Id i can use on my server to identify certain devices?


            public string GetDeviceId()
            {
                var packageSpecificToken = HardwareIdentification.GetPackageSpecificToken(null);
    
                var hardwareId = packageSpecificToken.Id;
                var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
    
                var array = new byte[hardwareId.Length];
                dataReader.ReadBytes(array);
    
                var sb = new StringBuilder();
    
                for (var i = 0; i < array.Length; i++)
                    sb.Append(array[i].ToString());
    
                return sb.ToString();
            }

    You'll need the following using:

    using Windows.System.Profile;


    British Airways Inspiration App & rara music

    • Marked as answer by kalel111 Saturday, September 21, 2013 3:51 AM
    Thursday, September 19, 2013 1:30 PM
  • Hi, kalel111

    Just as Flexman suggestion, you can use the HardwareIdentification.getPackageSpecificToken() method to get the ASHWID. This API will return different IDs when called by two apps from different packages. But ASHWID is generated using the components that make up the device, so you do not get unique device Id at all time. For example, the ASHWID ID will change each time when the bluetooth setting is changing.

    There is a best practice to use MAC address as the unique ID, we assume that all the device has at least one network adapter.

    The code is below:

    var networkProfiles = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
                var adapter = networkProfiles[0].NetworkAdapter;
                string networkAdapterId = adapter.NetworkAdapterId.ToString();
    

    You can also refer to this link:

    http://social.msdn.microsoft.com/Forums/windowsapps/en-US/62ac2a48-be60-465c-b3b7-bbb736a67a60/how-to-get-the-device-unique-id-and-mode-on-windows-8-ask-for-help-urgently

    Best Wishes!



    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by kalel111 Saturday, September 21, 2013 3:50 AM
    Friday, September 20, 2013 3:06 AM

All replies

  • I have a chatroom  app, and i want to be able to ban users using a unique Id, number , etc..

    Is there a way i can get the device ID of the user's computer/Tablet? If not. Is there any other unique Id i can use on my server to identify certain devices?


            public string GetDeviceId()
            {
                var packageSpecificToken = HardwareIdentification.GetPackageSpecificToken(null);
    
                var hardwareId = packageSpecificToken.Id;
                var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
    
                var array = new byte[hardwareId.Length];
                dataReader.ReadBytes(array);
    
                var sb = new StringBuilder();
    
                for (var i = 0; i < array.Length; i++)
                    sb.Append(array[i].ToString());
    
                return sb.ToString();
            }

    You'll need the following using:

    using Windows.System.Profile;


    British Airways Inspiration App & rara music

    • Marked as answer by kalel111 Saturday, September 21, 2013 3:51 AM
    Thursday, September 19, 2013 1:30 PM
  • Hi, kalel111

    Just as Flexman suggestion, you can use the HardwareIdentification.getPackageSpecificToken() method to get the ASHWID. This API will return different IDs when called by two apps from different packages. But ASHWID is generated using the components that make up the device, so you do not get unique device Id at all time. For example, the ASHWID ID will change each time when the bluetooth setting is changing.

    There is a best practice to use MAC address as the unique ID, we assume that all the device has at least one network adapter.

    The code is below:

    var networkProfiles = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
                var adapter = networkProfiles[0].NetworkAdapter;
                string networkAdapterId = adapter.NetworkAdapterId.ToString();
    

    You can also refer to this link:

    http://social.msdn.microsoft.com/Forums/windowsapps/en-US/62ac2a48-be60-465c-b3b7-bbb736a67a60/how-to-get-the-device-unique-id-and-mode-on-windows-8-ask-for-help-urgently

    Best Wishes!



    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by kalel111 Saturday, September 21, 2013 3:50 AM
    Friday, September 20, 2013 3:06 AM