How to find out if a UDID string is for an iOS device?

I am working on a Cocoa iOS application that has a reserve - if the user does not enter a certain part of the data, the device UDID is used instead, by default. I need to add a check to our server code (written in Ruby) to find out if the value being sent is UDID (user default) or the custom string they set.

It seems like the correct solution to my problem is regex. I am comfortable writing regex'es, but I have to make sure that this regular expression is 100% guaranteed to recognize UDIDs.

I am extracting the UDID in the code using:

[[UIDevice currentDevice] uniqueIdentifier]

And in the simulator I will return this value:

6938CA7D-ECE2-53A4-B293-961A8D07AFB1

From this, I can conclude that I can just look for a string of hexadecimal characters that matches the pattern 8-4-4-4-12. But I want to be sure that this works for every UDID.

I can't find anything about this in the Apple documentation and was wondering if anyone could give me a definitive answer to this question ... thanks!

+3
source share
3 answers

Why not send another bit of data indicating that it is a UDID? Or just use a different parameter name ( UDID=6938...).

Then on your server, you can check it like this if you really want to:

# somewhere outside the controller action, maybe the top of the file
UDID_PATTERN = /\A[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\Z/

# inside the controller action you're sending info to
udid = params[:UDID]
if udid && (udid =~ UDID_PATTERN)
  # do something with the UDID in place of the other
  # bit of info they could have provided
end
+1
source

You can not say. Apple documentation says:

( UDID ) -, , .

iPhone uniqueIdentifier iOS-. iPhone-, , UDID, 40 . .

UDID, , , ?

+2

, , , .

UDID . , , 100%.

+2

Source: https://habr.com/ru/post/1782463/


All Articles