Tuesday, March 15, 2011

iPhone udid Structure

udid is Unique Device Identifier. Every iPhone device has it's own udid.
Other smart phones (Android, Blackberry) also has an id that uniquely identifies the device.
udid value can be easily taken from the class UIDevice by using this simple objective C line:
NSString* udid = [UIDevice currentDevice].uniqueIdentifier;
I am currently working on a mobile installation tracking process. In order to track installations you must compare between the udid of the device when the installed application is first launched.

While conducting tests with udid, I noticed that iPhone udid structure is different when running on X-Code simulator comparing to running on a real device.
Where running on X-Code simulator the value contains the following pattern:

HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH
where "H" stands for Hex number. Note that if there are letters (A-F) they are capital.
For example:
79550EDC-2A86-5BDF-8EE2-219B7FCBD223
When running on a real device the udid value is 40 hex chars. The letters are small. Note that there are no minus ("-") characters used.
For example:

ce43446816952ff4513e1389c5e1d3ac3a856141
I think that the udid is different in the simulator and on a real device because the simulator simply return the udid of the Mac machine and the Mac machine udid string is different than the iPhone device udid.

No comments:

Post a Comment