1

I need to get iPhone unique number programmatically. I know that apple will reject app if I try to gain iPhone serial number.

But may be there is a way to get any unique number of iPhone, so server can distinguish  one device from another.

Paul T.
  • 4,938
  • 7
  • 45
  • 93
  • what kind of unique number ? A number that can identify each device ? Use MAC address. – Raptor Aug 27 '13 at 10:17
  • See this question here for a substitute: http://stackoverflow.com/questions/15939819/udid-replacement – Dan Aug 27 '13 at 10:18
  • First of you should never ever [identify device](http://triplesoftware.nl/2012/03/uniqueidentifier-deprecated-is-a-good-thing/), but you should identify user. Also as of iOS 7 you will not be able to identify device at all. – rckoenes Aug 27 '13 at 10:18
  • possible duplicate of http://stackoverflow.com/questions/15673882/apple-to-reject-any-apps-that-access-udids-dont-support-retina-iphone-5-displa – Master Stroke Aug 27 '13 at 10:20
  • http://www.doubleencore.com/2013/04/unique-identifiers/ and http://blog.appsfire.com/udid-is-dead-openudid-is-deprecated-long-live-advertisingidentifier/ – Pradeep Aug 27 '13 at 10:25
  • @rckoenes, you said, that in iOS 7 it will be not possible to use any device identifier. how about identifierForVendor? – Paul T. Aug 27 '13 at 10:43
  • The `identifierForVendor` or `advertisingIdentifier` can both be reset. The `advertisingIdentifier` can be reset by the user and the `identifierForVendor` will be reset if the user removes all app from the same vendor. Thus if the user wipes and reinstalls all the identifier will be reset. – rckoenes Aug 27 '13 at 11:11

3 Answers3

3

For each iPhone, MAC address is unique ( except for iOS Simulator ). You can obtain the information to identify the device. This question will guide you to get MAC address. However, iOS7 disallows use of MAC address. Therefore, for iOS 6 or before, you can use MAC address; for the coming iOS 7, you can use the following method.

Since iOS 6, Apple suggests to use Advertising Identifier, which can be found in ASIdentifierManager class. Example code:

NSUUID *uuid = [ASIdentifierManager advertisingIdentifier];
Community
  • 1
  • 1
Raptor
  • 53,206
  • 45
  • 230
  • 366
  • This will not work on iOS 7, not device identify number can be used in iOS 7. So there is no way to make this future proof. – rckoenes Aug 27 '13 at 10:19
  • @PaulGalavic for iOS 7 code, I have added in the updated answer. – Raptor Aug 27 '13 at 10:26
  • 1
    Apparently if your app doesn't use ads then will get rejected, so this isn't a complete solutoin :l see this SO thread => http://stackoverflow.com/questions/21489097/ – ipatch Apr 08 '15 at 23:25
  • @Chris not true. My app does not use Ads (I use the identifier to specify some devices to have special permissions instead), and gets approved by Apple multiple times. – Raptor Apr 09 '15 at 01:56
1

Have you looked at identifierForVendor?

https://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/identifierForVendor

Apple describe it as:

An alphanumeric string that uniquely identifies a device to the app’s vendor.

James
  • 667
  • 1
  • 5
  • 17
  • 1
    Be aware that this number can be changed if the user removes all the apps by the same vendor. Also all apps by different vendor will not have the same identifier. – rckoenes Aug 27 '13 at 10:21
  • will this number be ok in iOS7 ? – Paul T. Aug 27 '13 at 10:41
  • I can't find an Apple source for this -- but I've found several sites that quote the iOS7 "what's new" docs as saying: "Two low-level networking APIs that used to return a MAC address now return the fixed value 02:00:00:00:00:00. The APIs in question are sysctl (NET_RT_IFLIST) and ioctl (SIOCGIFCONF). Developers using the value of the MAC address should migrate to identifiers such as -[UIDevice identifierForVendor]. This change affects all apps running on iOS 7." – James Aug 27 '13 at 10:47
0

You should try this to get uid of your iPhone:

 NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];
TLama
  • 75,147
  • 17
  • 214
  • 392
AJC
  • 11
  • 1