Empty IMEI Number on iPhone 4S - iphone

I'm currently using Erica's code to get hold of the iPhone IMEI number programmatically: https://github.com/erica/uidevice-extension/blob/master/UIDevice-IOKitExtensions.m
This works fine on iPhone 3G and 4, even an iPhone 4 with iOS 5. But when I try it on a iPhone 4S, it returns empty.
Does the code I'm currently using need updating, or is there an alternate method to get the IMEI on the 4S?

In the end, due to fact that Apple is going to be restricting access to unique identifiers like the IMEI and the iPhone unique Id, I resorted to using some code from Georg Kitz which creates a unique identifier based on the MAC address of the phone, hashed using MD5.
Using Georg Kitz's code (https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5), I can simply get the Id as follows:
UIDevice * thisDevice = [UIDevice currentDevice];
thisDevice.uniqueDeviceIdentifier

Related

How to get IMEI Number in IOS 7 devices programmatically

I wrote the code for getting IMEI number in iPhone/iPad devices, it worked well IOS 6. Once I updated the OS version to IOS 7, app getting crash while executing IMEI number retrieval code. Is there any changes required to get the IMEI in IOS 7 devices?
Here is my code:
struct CTResult it;
CFMutableDictionaryRef kCTDict;
conn = _CTServerConnectionCreate(kCFAllocatorDefault, ConnectionCallback,NULL);
_CTServerConnectionCopyMobileEquipmentInfo(&it, conn, &kCTDict);
NSLog (# "kCTDict is %#", kCTDict);
CFStringRef meid = CFDictionaryGetValue(kCTDict, CFSTR("kCTMobileEquipmentInfoMEID"));
NSLog (# "kCTMobileEquipmentInfoMEID is %#", meid);
CFStringRef mobileId = CFDictionaryGetValue(kCTDict,CFSTR("kCTMobileEquipmentInfoCurrentMobileId"));
NSLog (# "kCTMobileEquipmentInfoCurrentMobileId is %#", mobileId);
I am not very sure about IMEI number in iOS7 Apple changed the way they provide the Unique Identifier. But you should not be getting IMEI in first place as you're using private API and this is against Apple rules.
To get unique identifier for device you should use UDID. This will always return the same id across all your apps running on the same phone.

Getting iPhone unique number

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.
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];
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.
You should try this to get uid of your iPhone:
NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];

Corebluetooth glitch on iPhone 4S?

I have been working extensively testing out the BLE capabilities of the iPhone 4s as well as the iPhone 5.
At the moment, all I have been accomplishing is pulling in the advertisement data from multiple TI BLE keyfobs and populating a UITableView with the kCBAdvDataLocalName, ManufacturingData, and ServiceUUIDs for each respective device.
Basically, as I pull in the advertisement data, I am also pulling in the peripheral's UUID and using this to populate the datasource array for the tableview. (i.e. if a new UUID is found and it is not in the datasource array, add it to the array and use that to retrieve the respective peripheral).
With the iPhone 5 this works flawlessly. However, when I test with an iPhone 4S (and I have tested with multiple) the BLE hardware pulls in NULL UUIDs therefore preventing me from adding any peripheral's info to the datasource array. In my console log, the phone does indeed discover each peripheral, and displays its localname, and manufacturing data, but every single device has a null UUID.
I have also ran my testing app on a 4S and a 5 simultaneously with the exact same code, and it will work on the 5 and not the 4S. So I was wondering if anyone has been having this same issue, whether it was a bug in the SDK or the hardware, or if there is a known workaround? Any feedback will be greatly appreciated, thanks.
The problem in iOS 6 is that the UUID's are not generated until you've actually connected to the device. UUID's are generated on the iOS side for each peripheral, so that's why you'll typically see a different UUID for the same peripheral when using different iOS devices. I usually check the UUID, and then if it is NULL, I will go off of the name. If the name is NULL however, then I do not populate it in the device list. Your other option is to quickly connect and then disconnect from the device. A big time hack, but it will generate the UUID and then be non-null from then on. Supposedly this problem will be fixed in the next version of iOS.

The iOS 5 changed the uniqueIdentifier code?

The function
[[UIDevice currentDevice] uniqueIdentifier]
Is deprecated in iOS 5 and I found the solution in this project using the MAC address: https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5
Ok, it is solved. But now I discovery that iOS 5 CHANGED the format of code that uniqueIdentifier return.
In iOS 4.x it is in this format:
93F38DEB-3C0B-5C09-B746-0DFDFDDB297C
Now the iOS 5, the same function return in this format:
93f38deB3c0b5c09b7460dfdfddb297c
Anyone know if the code changed at all? It is different only is format or the code in really different for the same device?
A MAC Address is a (supposedly) globally unique identifier attached to a network interface, though they can be changed in many ways.
The uniqueidentifier that Apple used to provide access to was attached to the device hardware and not changeable, which made it excellent for tracking a user across apps and sessions. That's also the reason Apple is removing it, if I had to guess. Not having a way to track users across apps and sessions increases a user's privacy on their devices.
I wouldn't be surprised if Apple removes access to the MAC Address eventually for the same reasons, so it might benefit you to examine other options for tracking devices.
[[UIDevice currentDevice] uniqueIdentifier] will still give you the same result as before. The project that you link to is not a 1:1 replacement, it is an alternative that gives you a similar solution using a different implementation, thus the two string are different.
You shouldn't use unique identifier on iOS 5. That's all you need to know.
The unique identifier on iOS was always something redundant and a big security threat. Other operating systems don't have unique identifiers and they can live without them.
You can always generate unique identifiers on your server and send them to your device.
You can always generate them from some unique system property (e.g. MAC), using system functions. On iOS you can create a unique identifier using CFUUIDCreate. This identifier is unique across devices and across time (you'll get a different identifier every time you call it) but you can save them (e.g. into keychain).
The code CHANGED!!!!!
UniqueIdentifier is no more UNIQUE!!!
The first format have 36 hexa lenght
93F38DEB-3C0B-5C09-B746-0DFDFDDB297C
The second have 40 hexa!!!!!
Because this, it changed. I don't know if it append more hexa to identifier, but the bigger size changed al all.

API to get an iPhones unique ID?

Two part question:
Does the iPhone have a unique ID other than it's MAC address?
If so, is there an API call I can use to get it?
(hopefully this isn't a duplicate, I couldn't find anything on SO)
The iPhone does have a unique identifier, called the UDID (this is the same identifier used when setting up a device for development or when doing ad hoc distribution). You can retrieve it as so:
NSString *uniqueIdentifier = [UIDevice currentDevice].uniqueIdentifier;