How to get IMEI on iPhone?

2019-01-01 09:27发布

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.

Any suggestion about how to get IMEI on iPhone?

6条回答
深知你不懂我心
2楼-- · 2019-01-01 09:29

I found that erica had posted the header file "Message/NetworkController.h" on ericasadun.com. http://ericasadun.com/iPhoneDocs300/_network_controller_8h-source.html (It's been removed now)

I created a header file, copy and paste the NetworkController.h file into it and add the private framework "Message.framework" to my project, import the header file I created.

Now I can use the original method I found to get the imei number.

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

[EDITED] Doesn't work anymore. App will be rejected by Apple. Instead you will have to use UDID. See post below.

查看更多
人气声优
3楼-- · 2019-01-01 09:49

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);
查看更多
骚的不知所云
4楼-- · 2019-01-01 09:50

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.

查看更多
明月照影归
5楼-- · 2019-01-01 09:53

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

查看更多
看淡一切
6楼-- · 2019-01-01 09:53

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

查看更多
还给你的自由
7楼-- · 2019-01-01 09:54

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

查看更多
登录 后发表回答