Sunday, July 14, 2013

Windows Phone Tip: Getting the Device GUID

Sometime you may want to uniquely identify a Windows Phone, such as when you are implementing push notifications. The best way to identify a unique Windows Phone is through its device GUID.

The following code snippet shows how to obtain the GUID of a Windows Phone device:

using Microsoft.Phone.Info;

    public static byte[] DeviceId()
        object uniqueId;
        if (DeviceExtendedProperties.TryGetValue(
        "DeviceUniqueId", out uniqueId))
            return (byte[])uniqueId;
        return null;

    byte[] guid = DeviceId();           
    MessageBox.Show("Device GUID - " +


For the code above to work, you need to check the ID_CAP_IDENTITY_DEVICE setting in your WMAppManifest.xml file.

No comments: