How to get IMEI on iPhone?
Asked Answered
L

7

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?

Lowborn answered 5/5, 2009 at 3:24 Comment(0)
L
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.

Lowborn answered 15/1, 2010 at 7:53 Comment(8)
Erica has posted a new way to get IMEI here: github.com/erica/uidevice-extension/blob/master/…Lowborn
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.Lowborn
@iPhoney Have you tried to use Erica's code and submit app to Apple? Just wonder if it will get approved or not. Thanks!Commutate
Thanks for this. I also want to know if it will be banned by appleAprilette
I also want to know if it will be banned by apple or not, thanksPyro
@Mighter: What doesn't work on iPhone 4S, the code in the answer or the code on GitHub in the first comment?Qualifier
@iPhoney - application is crashing while getting imei, i am doing like this NSLog(@"%@",[UIDevice currentDevice].imei);Covenant
@Covenant 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..Infuriate
U
7

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

Upspring answered 5/5, 2009 at 4:17 Comment(0)
W
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.

Willing answered 5/5, 2009 at 9:46 Comment(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?Soule
S
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.

Sidero answered 5/5, 2009 at 4:20 Comment(2)
what is #06# ? Can you explain a little more?Lowborn
dialing *#06# on all cell phones that I know of will show their IMEI. That's star-hash-zero-six-hash.Sidero
D
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://mcmap.net/q/343076/-finding-imei-number-using-objective-c-duplicate

Dieback answered 1/8, 2014 at 10:47 Comment(0)
T
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);
Trollope answered 21/11, 2012 at 9:52 Comment(3)
does not work for me when I test it on iPhone simulator (returns empty) is that expected ?Cold
Please test this on real iPhone, I tested this on iPhone4 ,ios5.1.1Trollope
no, apple wont accept this. i found my answer here https://mcmap.net/q/343076/-finding-imei-number-using-objective-c-duplicateAnglicism
C
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.

Cascara answered 23/9, 2020 at 17:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.