51

I need to find a way to get the IMEI number of an iPhone device. This question is not a duplicate.

I have gone through several forums including SO, and had no luck finding an answer.

Some say Apple doesn't allow developers to see the IMEI number (SO post), and some say to use UDID instead (SO post). Some say that UDID is deprecated (in iOS 7).

I need to know the following:

1.) Does Apple permit developers to retrieve the IMEI number of the device?

2.) How can i programatically do it?

3.) In case if Apple doesn't allow developers to gather the IMEI number, do they provide any other unique number for the device?

4.) Some suggest to use Telephony framework. If i do so, will apple reject my application?

Community
  • 1
  • 1
Sharon Watinsan
  • 9,620
  • 31
  • 96
  • 140
  • 2
    UDID is deprecated. What is your solution ? – Sharon Watinsan Nov 12 '13 at 10:54
  • 1
    instead of UDID you can use identifier for vendors. (https://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/identifierForVendor) Ref.http://stackoverflow.com/questions/4270200/how-can-i-retrieve-the-udid-on-ios/19046651#19046651 – Nirav Gadhiya Nov 12 '13 at 10:57
  • 1
    I read the description, and i don't think it can be use to uniquely identify a device. `A different value is returned for apps on the same device that come from different vendors,...` – Sharon Watinsan Nov 12 '13 at 11:00
  • Apple don't want you to uniquely identify devices. You can't beat the system. – David Snabel-Caunt Nov 12 '13 at 11:05

5 Answers5

79

Apple does not allow you to identify a device any more.

UDID, MAC address and all other device identifiers are no longer accessible or allowed by Apple.

Apple suggest that you use either UUID (which you will need to store your self or), identifierForVendor or advertisingIdentifier.

Apple is now also rejecting app that use the advertisingIdentifier and not showing any advertisements apps.

Any means to get the IMEI number are using private methods, which is also not allowed by Apple anymore. And your mobile app might/will get rejected because of this.

waza
  • 486
  • 9
  • 19
rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • 3
    @sharonHwk No, Apple does not longer allow you to identify a unique device. – rckoenes Nov 12 '13 at 11:05
  • 1
    now if you use the advertisingIdentifier but your app doesn't have ad. then your app may be rejected by Apple. – frank Mar 28 '14 at 13:44
  • Pray for identifierForVendor. Apple, do not deny it! – Almas Adilbek Jul 02 '14 at 05:08
  • Good answer, but Any Solution for the Actual question. – Parth Pandya Feb 02 '16 at 10:15
  • 2
    @ParthPandya the fact that Apple does not allow it means that this is the answer. Unless you are developing for jailbroken devices, but since I have no experience with this I can answer it. – rckoenes Feb 02 '16 at 10:19
  • @RayKing mind your language. Also Apple has very good reasons for this. Mainly privacy, Apple does what ever it can to protect the users privacy. This include any type of device identification. Thus protecting the users privacy better then any other platform. – rckoenes Apr 12 '17 at 09:21
  • but it still unfair to developers. what if I want to ban user from using my app? They will delete the app and create new account and keep spamming. not cool.. – Yaroslav Dukal Apr 12 '17 at 09:22
  • 1
    You can still store some unique identifier in the keychain which only your app can access. You can then still block this user. Even better that most user share there keychain with their other devices. Also what if you locked out a device and then the user sells their device the new user can't use you app. This is why identifying device is not correct. – rckoenes Apr 12 '17 at 09:26
  • Personally, I think this is ridicolous. The issue here is that this only hinders "good" developers and does little to stop the real problem, i.e. the ones who abuse/misuse this information. – Andrea Raimondi Aug 03 '17 at 19:38
  • I want to use IMEI or IMSI number for an app which will be used only internally by my company for testing purposes. This app will not be on the App Store for public distribution. Is there a possibility to get IMEI or IMSI for this internal purpose and not for public distribution? – Ram Ramesh Apr 25 '19 at 23:35
  • NSString *UDIDString = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; – Breno Medeiros de Oliveira Apr 01 '22 at 14:04
17

Unfortunately, there is no way to get a unique identifier for a device which will always remain the same. Apple no longer allows you to access the UDID. And in iOS 7, all devices' MAC addresses return the same value, so that is no longer useful either.

However, iOS does now give access to two types of identifiers which can be used to identify a device. They are:

  1. Vendor ID - [UIDevice identifierForVendor]. This is a unique identifier which is the same for all apps from the same vendor or company. It will remain the same, so long as the user has at least one app from the vendor installed on their device. So if you have 3 apps, the vendor ID will remain the same unless the user uninstalls all three apps, and then reinstalls. This is not so useful if you only have one app - if the user deletes it and then reinstalls it, it will change.

  2. Advertiser ID - [UIDevice advertisingIdentifier]. This is a unique identifier meant for advertising purposes. But if you use it for non-advertising purposes they, for the most part, won't care. Under most circumstances, the advertising identifier will not change, even if the user deletes and reinstalls the app. However, there is an option in the iOS settings to reset the advertising identifier, which will change it. This is meant to that users can choose to disassociate themselves from any advertising information which has been collected about them. But this is a very advanced setting and I doubt that many users would do this frequently enough that it would be a problem for you.

Jason
  • 14,517
  • 25
  • 92
  • 153
  • 3
    According to a couple of blog posts I found, it's not OK to use the advertisingIdentifier for non-advertising purposes. E.g. Pixtant has been rejected twice for not showing ads: http://moneyfromapps.com/we-found-your-app-uses-the-ios-advertising-identifier-but-does-not-include-ad-functionality-idfa/ - Apple's clause for rejection: “You and Your Applications (and any third party with whom you have contracted to serve advertising) may use the Advertising Identifier, and any information obtained through the use of the Advertising Identifier, only for the purpose of serving advertising. [...]” – Anton Kaiser Aug 29 '14 at 06:12
  • Actually, every time I release an app on the store, there are tick boxes for ADID, and a comment from Apple that they will remove the app and hold me _personally_ liable if I lie about it. – gnasher729 Mar 19 '21 at 08:38
7

You can obtain IMEI using private frameworks -See this Question but probably your app will be rejected from app store then.

If you want to obtain some device identifier to use in your application you must use uniqueIdentifier property defined in UIDevice class

(Available in iOS 6.0 and later):

NSString *UDID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
Community
  • 1
  • 1
Guntis Treulands
  • 4,764
  • 2
  • 50
  • 72
1

You can save UUID in keychain and user it as unique number. It won't change until user will reset iOS.

えるまる
  • 2,409
  • 3
  • 24
  • 44
0

If you want to obtain the IMEI there is no way (on a non-jailbroken device). If you wish to identify the user take a look at this answer. Please pay attention to all documentation/answers written before iOS7 since things have changed.

Community
  • 1
  • 1
Fr4ncis
  • 1,387
  • 1
  • 11
  • 23