打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
How to get IMEI on iPhone 5


I'm develop application for jailbroken iOS devices. I use https://github.com/erica/uidevice-extension/blob/master/UIDevice-IOKitExtensions.m to get IMEI, but on iPhone 5 this solution does not work(return empty string). Is there any way to get IMEI on iPhone 5(iOS 6.1.2)?

share|improve this question

There are several ways to get IMEI on newer devices

1) Private ManagedConfiguration.framework

CFStringRef MCCTIMEI()

2) CoreTelephony.framework

struct CTResult
{
    int flag;
    int a;
};
extern CFStringRef kCTMobileEquipmentInfoIMEI;

void *connection = _CTServerConnectionCreate(kCFAllocatorDefault, NULL, NULL);

NSDictionary *info = nil;
struct CTResult result;
_CTServerConnectionCopyMobileEquipmentInfo(&result, connection, &info);
[info autorelease];    
CFRelease(connection);

NSString* IMEI = (NSString*)info[(NSString*)kCTMobileEquipmentInfoIMEI];

3) liblockdown.dylib

extern CFStringRef kLockdownIMEIKey;

void* connection = lockdown_connect();
NSString* IMEI = [(NSString*)lockdown_copy_value(connection, NULL, kLockdownIMEIKey) autorelease];
lockdown_disconnect(connection);

I had some problems with MCCTIMEI - returned empty IMEI after device start-up. Now I'm using CoreTelephony solution, never had a problem with it.

UPDATE

On iOS 7 these APIs are protected by com.apple.coretelephony.Identity.get. entitlement. To access IMEI (IMSI, phone number and other info) you need to sign your with that entitlement with boolean value set to true.

share|improve this answer
   
tnx for reply, I'm try) –  InViZz May 22 '13 at 8:32
   
Sadly, none of those methods will return the IMEI on iOS7 –  Mobster Nov 9 '13 at 20:45
   
@Mobster, these APIs are probably protected by entitlement in iOS 7. I think it's com.apple.coretelephony.Identity.get. –  creker Nov 9 '13 at 23:05
   
@creker, to use the com.apple.coretelephony.Identity.get, the device must be jailbroken, right? –  MobsterNov 11 '13 at 16:08
1 
Yes, device must be jailbroken. As for entitlement, it's just a guess. I looked at Preferences app (it has access to this kind of information, including IMEI) entitlements, found one that's looks like it has something to do with IMEI. Preferences app in iOS 6 doesn't have this entitlement so I assumed it's the reason why these APIs stopped working. We just have to wait for jailbrake to test it. –  creker Nov 11 '13 at 17:40

It have some difficult get the IMEI number programatically. However, if you're looking for a way to identify a particular phone, you can use the UDID (Unique Device Identifier) to do so.

NSString *UDID = [[UIDevice currentDevice] uniqueIdentifier];

and also try this for IMEI

NSString *imei = [[NetworkController sharedInstance] IMEI];
share|improve this answer
2 
thx for reply, but uniqueIdentifier is deprecated –  InViZz May 22 '13 at 8:32

You can use it:


Download following two files from GitHub

OpenUDID.h
OpenUDID.m

Add these files to your project.

And use it as

#import "OpenUDID.h"

NSString* openUDID = [OpenUDID value];

It is tested in iPhone 4 and iPhone 5


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.

share|improve this answer
   
Actually, UDID is deprecated on iOS7 (along with Open UDID and MAC Address). The correct way is to replace it with UUID, identifierForVendor or advertisingIdentifier, depending of your needs. Check the following to see how you can get the UUID and store it in the keychain:github.com/joseandro/TitaniumiOSUniqueIDs/blob/master/Classes/… –  Mobster Nov 9 '13 at 19:35

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
不进行APP埋点的情况下,SDK可以收集到哪些数据?
iOS获取设备唯一标识的各种方法?IDFA、IDFV、UDID分别是什么含义?
现有IOS设备唯一标示符的方案比较
对IOS设备中UDID的一些思考
在 iOS 7 中获取唯一标识符(UDID/UUID) | zrong's blog
iOS7获取设备UDID、IMEI、ICCID、序列号、Mac地址等信息
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服