22

I want to get IMEI on iPhone. I try to use the following code:

#import "Message/NetworkController.h"
NetworkController *ntc=[[NetworkController sharedInstance] autorelease];
NSString *imeistring = [ntc IMEI];

But NetworkController is not found.

I also find that I can get uniqueIdentifier using:

UIDevice *myDevice = [UIDevice currentDevice];
NSString *identifier = myDevice.uniqueIdentifier;

But this cannot help me to get IMEI.

How to get IMEI on iPhone?

Cœur
  • 32,421
  • 21
  • 173
  • 232
Chilly Zhong
  • 16,373
  • 23
  • 75
  • 103

7 Answers7

13

You can't get IMEI on iPhone anymore. You may have to use UDID instead. See other answers.


In the past, you could use the header file "Message/NetworkController.h" posted on ericasadun.com. http://ericasadun.com/iPhoneDocs300/_network_controller_8h-source.html (It's been removed now)

You would add the NetworkController.h file and the private framework "Message.framework" to your project, then import that header file to use the original method I found to get the imei number:

NetworkController *ntc = [NetworkController sharedInstance];
NSString *imeistring = [ntc IMEI];

That hack doesn't work anymore. App will be rejected by Apple.

Cœur
  • 32,421
  • 21
  • 173
  • 232
Chilly Zhong
  • 16,373
  • 23
  • 75
  • 103
  • 4
    Erica has posted a new way to get IMEI here: http://github.com/erica/uidevice-extension/blob/master/UIDevice-IOKitExtensions.m – Chilly Zhong Sep 07 '10 at 02:06
  • No, it's a private framework on iOS3. There's no need to use it now coz erica has posted a new way of getting imei. – Chilly Zhong Nov 08 '10 at 15:41
  • 2
    @iPhoney Have you tried to use Erica's code and submit app to Apple? Just wonder if it will get approved or not. Thanks! – topace Oct 10 '11 at 11:12
  • 1
    Thanks for this. I also want to know if it will be banned by apple – ThinkChris Mar 22 '12 at 22:14
  • I also want to know if it will be banned by apple or not, thanks – Glenn S Aug 08 '12 at 05:50
  • @Mighter: What doesn't work on iPhone 4S, the code in the answer or the code on GitHub in the first comment? – newenglander Apr 08 '13 at 12:02
  • @iPhoney - application is crashing while getting imei, i am doing like this NSLog(@"%@",[UIDevice currentDevice].imei); – Rajneesh071 May 07 '13 at 10:00
  • @Rajneesh071 have you got any solution to get IMEI number, even using private frameworks.. even i tried with these libraries, its crashing when i use that line of code.. – vishy Aug 29 '13 at 16:02
7

You can't find the IMEI programmatically on the iPhone.

Jane Sales
  • 13,506
  • 3
  • 50
  • 56
4

There is no official way to get it, but in Apples private framework CoreTelephony.framework there is a method CTGetIMEI that might help you.

mattes
  • 7,580
  • 1
  • 38
  • 64
oxigen
  • 6,193
  • 3
  • 25
  • 36
  • 1
    I am using CoreTelephony frame in one of the apps. But unable to figure out how I can use __CTGetIMEI functions to get the IMEI number of the iPhone? Can you please help? – AJ. Dec 17 '09 at 11:57
3

I'm sure there are reasons you can't do this easily. Auto-unlocker app? I don't think so. I'm sure Apple and AT&T wouldn't like it too much either.

*#06# is the way to get it manually.

bsneeze
  • 3,979
  • 22
  • 20
2

I made a search only here in stackoverflow and the conclusion is that Apple dont allow anymore to find phone EMEI after iOS 6.

You can identify a device using UDID. I found my answer here https://stackoverflow.com/a/19927376/2283308

Community
  • 1
  • 1
Pedro Romão
  • 1,925
  • 23
  • 20
1

add a head file "CoreTelephony.h" to your project

CoreTelephony.h

struct CTServerConnection
{
    int a;
    int b;
    CFMachPortRef myport;
    int c;
    int d;
    int e;
    int f;
    int g;
    int h;
    int i;
};

struct CTResult
{
    int flag;
    int a;
};

struct CTServerConnection * _CTServerConnectionCreate(CFAllocatorRef, void *, int *);

void _CTServerConnectionCopyMobileIdentity(struct CTResult *, struct CTServerConnection *, NSString **);

add the following code to your class

#import "CoreTelephony.h"

struct CTServerConnection *sc=NULL;
struct CTResult result;
void callback() { }

now, you can get imei easily

    NSString *imei;
_CTServerConnectionCopyMobileIdentity(&result, sc, &imei);
Vanguarder
  • 398
  • 3
  • 8
0

https://www.telesign.com/products/phone-id

There is an SDK by a company called TeleSign that can get a device's IMEI number (in addition to a list of other things such as carrier, the home address of the device's owner, etc.). Some of the biggest apps in the store use this provider (like Tinder and Evernote). I don't work for the company or ever have, or ever want to, and I've never used any of their products. I also don't know if Apple would reject this API usage. But if you want a Swift/Objecive-C interface for getting an IMEI number, this is one.

MJ-12
  • 8,200
  • 2
  • 25
  • 33