Oxygene and Windows Phone 8 tutorials – Article Index
In Windows Phone 8, you can easily get the Unique Device ID using the DeviceExtendedProperties.GetValue or DeviceExtendedProperties.TryGetValue method.
In order to retrieve the Unique Device ID in Windows Phone, the developer should also include the ID_CAP_IDENTITY_DEVICE capability in the WMAppManifest.xml file.
When this is not included, you will receive the following message when trying to executing the code.
“An exception of type ‘System.UnauthorizedAccessException’ occurred in Microsoft.Phone.ni.dll but was not handled in user code”
How to get the Unique Device ID in Windows Phone using Oxygene?
The DeviceExtendedProperties.GetValue returns the byte array which in turn can be converted to base64 string to retrieve the unique device id.
var DeviceID: array of System.Byte := array of System.Byte(Microsoft.Phone.Info.DeviceExtendedProperties.GetValue('DeviceUniqueId')); var UniqueDeviceID: System.String := Convert.ToBase64String(DeviceID); MessageBox.Show(UniqueDeviceID);