سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

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

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.

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

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);

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top