Because this is slightly out of date now I am just giving an up to date answer.
Because Apple
has seen fit to stop developers using the [[UIDevice currentDevice] uniqueIdentifier];
from iOS 6
onwards which Suhail Patels
answer advices to use. They have now started telling developers to use [[UIDevice currentDevice] identifierForVendor];
, but some developers are confused on whether they are still allowed to use uniqueIdentifier
even if they are still developing for iOS 5
and below or not. Apple
have been a bit fussy about this just saying :
"Apps that use the `UDID` will be rejected in the App Store review process.."
Come on Apple
give us a bit more detail.
Anyway because of the confusion behind this some developers have started using OpenUDID to get a unique identifier. Here is some code on how it can be used:
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
// Use: [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
// Use: [OpenUDID value];
}
EDIT
Some developers have also now seen fit to start using the MAC Address since UDID
has been deprecated. This is because the MAC addresses are hardware based and therefore can't be changed. For those of you that which to go for the MAC Address way apple have provided some sample code on Getting MAC Address.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…