This question already has answers here:
How to get IMEI on iPhone?
(7 answers)
Closed 2 years ago.
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?
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.
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:
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.
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.
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];
You can save UUID in keychain and user it as unique number. It won't change until user will reset iOS.
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.
Related
This question already has answers here:
UIDevice uniqueIdentifier deprecated - What to do now?
(32 answers)
Closed 5 years ago.
In my app, I am trying to get all information of the device and to be displayed in app screen.
I got some of the informations, but not getting code to obtain UDID, Serial number and model identifier of a device, what we can able to see in iTunes.
I can able to get UUID, but my request is to get UDID of the device. I got some apps in which they are getting device info like this.
I will be very helpful if I get any solution in this.
Thanks in advance.
You can't as of iOS 6.
Link #1
Money quote:
As reported by 9to5Mac (and confirmed by Macworld), Apple alerted
developers of a cut-off date for new apps or app updates that access
an iOS device’s UDID (Universal Device ID), an area of security and
privacy concern.
Link #2
Extended money quote:
With iOS 6 Apple has also completely eliminated its controversial
Universal Device IDs (UDID) and replaced it with a more
privacy-friendly way for application vendors and advertisers to
identify specific devices, Hall said,
Apple’s UDIDs are basically a set of alphanumeric characters that are
used to uniquely identify an iPhone or iPad. The numbers are designed
to let application developers track how many users have downloaded
their application and to gather other information for data analytics.
From the same article, the way to go now is:
With the new iOS 6 the company has gone one step further by
eliminating UDIDs completely and replace with a set of three new devie
identifiers. One is a vendor specific identifier that can be used by
application vendors to recognize specific devices, another is designed
for use by online advertisers and the third is an application-specific
ID. Unlike UDID’s, the new identifiers are not persistent and can be
cleared, though the device has to be completely reset to get rid of
the advertiser identities, Hall said.
In conclusion, the correct way is to either (a) use UUID or (b) ask your user for the device's UDID.
You can use this (Swift 3):
UIDevice.current.identifierForVendor!.uuidString
This question already has answers here:
Unique Identification of iOS device for iOS 7.0 and above
(6 answers)
Closed 6 years ago.
In my iOS app, I have to restrict the user to use iOS app per device. To do this I found a solution that we can use the UUID (Universally Unique Identifier) or UDID (Unique Device Identifier). But according to this answer I can't use UUID, because if app gets deleted or reinstalled UUID has been getting changed and I don't want this. Also Apple rejects apps if app uses UDID.
Is there any way to identify iOS device uniquely.
Apple has done away with the approach of UDIDs and will reject apps that use the same for unique device identification.
Source: TNW
What you are looking for is Vendor ID
I'm using this library for my projects, and it's working like a charm, please try :
https://github.com/blackpixel/BPXLUUIDHandler
easy to use :
Import BPXLUUIDHandler.h
Retrieve the UUID with
[BPXLUUIDHandler UUID]
Thats all...
Here is some info from project's github page :
As of iOS 5, Apple has deprecated the device unique identifier api and
hasn’t provided a friendly Obj-C replacement, instead recommending
CFUUIDCreate and NSUserDefaults.
CFUUIDCreate isn’t very complicated and neither is NSUserDefaults, but
this solution fails in a few different ways:
It’s not a quick one-shot call to get the UUID; you have to write your own wrapper to make it friendly
It doesn’t persist; deleting the app blows away the UUID (can be persisted if stored in the keychain though)
There’s no way to share it between apps
I have done a lot of research on this so please read the question before marking this as similar to some other question.
Our app needs to uniquely determine an iPhone such that even when user completely wipes a phone, when he runs our app we can be sure that it is the same device. The most important thing is we also need to determine devices over multiple Apple ID users so suggestions containing Keychain access and uniqueVendorID might not work as those change when another user starts using that phone. And as I have read using MAC addresses and old UDID for devices is not longer available as of iOS 6.0. I went through [UIDevice identifierForVendor] but this NSUUID changes when all the app by the same vendor has been uninstalled Reference.
I have looked through these resources:
UIDevice uniqueIdentifier Deprecated - What To Do Now?
and
What is a long-term method I can use to uniquely identify an iOS device?
I can not disclose the nature of work that my app performs due to non-disclosure, but to clarify what I require:
Multiple users might use our app on same phones, I need a way to know that the device user A used before and has reported to have handed over to user B is the same device on which our app was run. Is there any way to achieve this?
There's no way to achieve this.
If it's really the case that different users might use your app on the same device after a factory reset of the device, then what you want is not possible. Apple deprecated UIDevice uniqueIdentifier which would have been the way to do this.
as long as they dont restore/wipe the device identifierForVendor is ok
Apple is changing their privacy settings for iOS6 and deprecating device UUIDs (UDIDs). According to a WWDC presentation and the docs there are two replacements for the UDIDs, both in the UIDevice class:
-identifierForVendor
ID that is identical between apps from the same developer.
Erased with removal of the last app for that Team ID.
Backed up.
-identifierForAdvertising
Unique to the device.
Available to all applications; used for advertising — iAd has converted from UDID for iOS 6 and later.
Reset with "Erase All Content & Settings".
Backed up.
It seems to me that -identifierForVendor is inferior to -identifierForAdvertising since it would get reset on last uninstall of an app from a vendor and by "erase all contents & settings".
What advantages does -identifierForVendor have over -identifierForAdvertising?
Important Note:
Apple just released iOS 6.0 and the NDA has been lifted.
For developers who preemptively included code that referenced
[[UIDevice currentDevice] identifierForAdvertising]
this method has NOT been included on iOS 6. If you use the above method, your app will (most likely) crash and be rejected!
Instead, Apple has created a new class ASIdentifierManager , which includes the method advertisingIdentifier. Here's the apple docs on it:
Users can limit the use of ad tracking on their phone. See this article on the opt-out mechanism under Settings > General > About > Advertising.
The new ASIdentifierManager class has a property advertisingTrackingEnabled, which returns true or false depending if the user has limited ad tracking. Even though the device's advertising identifier is returned by the advertisingIdentifier property regardless of opt-out, you aren't supposed to use the identifier if the user has opted-out.
So the advantage of identifierForVendor is that you'll always have access to and the right to use this id for the phone regardless of user's opt-in or opt-out for advertising tracking.
I suspect that Apple will simply reject your app if you use identifierForAdvertising for anything that is not advertising-related (i.e., if you send the identifierForAdvertising to your own servers even though you're not an advertising network or if you send the identifierForAdvertising in the same request with other data that could potentially identify an individual).
If my suspicion is correct, the advantage of identifierForVendor over identifierForAdvertising is that it won't get your app rejected.
They are two different ids meant for two different purposes.
I would think that the identifierForVendor would be the one to use to do things that require the app linking to a specific user / device such as provide push notifications and updating the user's app data serverside (like their score or whatever other data is being stored for them).
The identifierForAdvertising should be used for things such as targeted advertising and also to check the effectiveness of a particular ad campaign (check to see which devices installed apps due to a particular ad).
Use the VendorID.
This is a very enlightening article http://www.doubleencore.com/2013/04/unique-identifiers/
To create a uniqueString based on unique identifier of device in iOS 6:
#import <AdSupport/ASIdentifierManager.h>
NSString *uniqueString = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
NSLog(#"uniqueString: %#", uniqueString);
Those APIs are so badly designed, that clearly says - Apple does not want us to identify user devices.
Just look at the identifierForVendor description.
It is erased if the user erases all apps from the same vendor. :(
It is not reliable - can return nil (documentation advices to "wait" for some time if this happens. :(
They did not use obvious solution, which works anytime and does not rely on installs/removes - return SHA-1 (or any other hash) of internal hardware device id concatenated with Team ID.
identifierForAdvertising is probably superior in terms of tracking but might be subject to present or future opt-out by the user. On the other hand identifierForVendor is not as likely to be subject of the user.
The important thing to know is that the backup of the identifierForVendor can only be restored to the same device. If the backup is restored to a difference device the identifier is cleared.
User can change identifierForAdvertising any time in Settings,
identifierForVendor changes after reinstall app, if no more apps on device from this vendor.
Here is alternative and the best solution for get or persistent, cross-install Device Identifier:
description: https://blog.onliquid.com/persistent-device-unique-identifier-ios-keychain/
code: https://gist.github.com/miguelcma/e8f291e54b025815ca46
The project I am on is requesting two (or even three) unique identifiers from the iPhone or iPad. I know, I know... the UDID should be enough but we are trying to see if there are any other unique identifiers that we can use.
I can get the IMEI, serial number, MAC Address, etc. from the phone using the IOKit.framework but apparently this is frowned upon by Apple and any app using this framework will be rejected.
Does anyone have any other ideas, or identifiers that I am missing that could be used?
Thanks!
This question is old however a new unique, vendor based, identifier has now been added to replace the deprecated UUID in iOS 6.
The [UIDevice identifierForVendor] should now be used instead of [UIDevice uniqueIdentifier] which is now deprecated as of iOS 5.0
Example usage:
NSUUID *uuid = [[UIDevice currentDevice] identifierForVendor];
NSString *uuidString = [uuid UUIDString];
You can get the ICCID and the IMSI (if they exist).
NSString *commcenter = #"/private/var/wireless/Library/Preferences/com.apple.commcenter.plist";
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:commcenter];
NSString *ICCID = [dict valueForKey:#"ICCID"];
NSString *IMSI = [dict valueForKey:#"IMSI"];
I think that's as far as you will get. I don't know any other options for getting an universal ID.
UPDATE 2013-03-13:
This has probably changed since I wrote this answer almost two years ago. I don't even remember what was the iOS version at the moment. Also as #joshis correctly pointed out in the comments "You cannot legally do this, since your app would read stuff from outside the application sandbox and therefore, it will be rejected, as specified in AppStore Review Guidelines...".
From Apple:
The value in this property remains the same while the app (or another
app from the same vendor) is installed on the iOS device. The value
changes when the user deletes all of that vendor’s apps from the
device and subsequently reinstalls one or more of them.
So if you use [UIDevice identifierForVendor] and the user delete the app and reinstall it, the id will be different(so no real physical device tracking)
Why don't you use SecureUDID?
NSString *domain = #"com.example.app";
NSString *key = #"mykey";
NSString *udid = [SecureUDID UDIDForDomain:domain usingKey:key];
This way, even if the user delete the app and reinstall it, the UDID will be same. This will give you consistent tracking(or whatever you want to do with the UDID).
Btw, the above is still permitted from Apple.
Have fun.
The method for getting the UDID is being deprecated, you should now use CFUUIDCreate which I think could be used multiple times to get more identifiers if needed
Perhaps you should clarify your question.
requesting two (or even three) unique identifiers from the iPhone or iPad
…is a contradiction in terms. If your purpose is to track a specific physical device, then a single unique identifier, by definition, is enough. That’s what unique means.
Perhaps, what you really want is to track multiple things about each user’s use of your app, as opposed to the device. Say your networked game app allows the user 1, 2, or 3 different personalities. As they user creates a distinct personality, you must track each of that user's personalities amongst all the other user’s personalities.
For this kind of purpose, generating and storing a UUID* is a proper and common solution. iOS includes libraries to generate a UUID value. The only catch is that if the user deletes and re-installs the app, the storage of that UUID may be lost. There are workarounds for this challenge, which you may learn about by googling for discussions of replacing UDID tracking with generated UUID values.
This question is a bit older. So I should mention: In iOS 5, Apple deprecated the use of the UDID. As of 2013-05-01 Apple is rejecting any app that accesses the UDID.
(*) Do not confuse a UUID with a UDID. UUID is a standard 128-bit (32 hex digits) number often used as a virtually unique identifier in many technology scenarios. UDID is Apple's 40 hex digit string burned into every iOS device to uniquely identify each device.
DeviceCheck API in iOS 11 is an interesting solution to get unique Identifier, the advantage it has is - the value will be retained even after the app in uninstalled. So use cases like trial installation and rewards can be effectively controlled by developers.