Question

Why is the Capability ID_CAP_IDENTITY_DEVICE is missing in Wp8.1? Due to this I am not able to get Device ID matching the one i am getting in WP8!

And this in turn is causing lot of issues in App Upgradation!

Now I am using,

HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null);
IBuffer hardwareId = token.Id;
HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm("MD5");
IBuffer hashed = hasher.HashData(hardwareId);
string DeviceId = CryptographicBuffer.EncodeToHexString(hashed);
return DeviceId ;

Previously we used,

DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId);
result = (byte[])uniqueId;
string id = Convert.ToBase64String(result).Replace("=", "").Replace("/", "").Replace("+", "");
return id + "";

Please suggest a solution so that we can get similar IDs in both platforms!

All help and suggestions appreciated.

Was it helpful?

Solution

If you are developing a Windows Phone 8.1 XAML app, it wont support ID_CAP_IDENTITY_DEVICE as it can be deployed on any device ie phone, tablet or desktop. So instead you can use the HardwareIndentification class to get device ID

private string GetDeviceID()
        {
            HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null);
            IBuffer hardwareId = token.Id;

            HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm("MD5");
            IBuffer hashed = hasher.HashData(hardwareId);

            string hashedString = CryptographicBuffer.EncodeToHexString(hashed);
            return hashedString;
        }

This may be helpful. Guidance on using the App Specific Hardware ID (ASHWID) to implement per-device app logic

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top