ios 如何在 iPhone 上获取 IMEI?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/823181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 15:53:23  来源:igfitidea点击:

How to get IMEI on iPhone?

iosobjective-ciphoneimei

提问by Chilly Zhong

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

我想在 iPhone 上获取 IMEI。我尝试使用以下代码:

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

But NetworkController is not found.

但是没有找到 NetworkController。

I also find that I can get uniqueIdentifier using:

我还发现我可以使用以下方法获得 uniqueIdentifier:

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

But this cannot help me to get IMEI.

但这不能帮助我获得 IMEI。

How to get IMEI on iPhone?

如何在 iPhone 上获取 IMEI?

采纳答案by Chilly Zhong

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

您无法再在 iPhone 上获取 IMEI。您可能必须改用 UDID。查看其他答案。



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)

过去,您可以使用 ericasadun.com 上发布的头文件“Message/NetworkController.h”。 http://ericasadun.com/iPhoneDocs300/_network_controller_8h-source.html(现已移除)

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.h 文件和私有框架“Message.framework”添加到您的项目中,然后导入该头文件以使用我找到的原始方法来获取 imei 编号:

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

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

那个黑客不再起作用了。应用程序将被苹果拒绝。

回答by Jane Sales

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

您无法在 iPhone 上以编程方式找到 IMEI。

回答by oxigen

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

没有获得它的官方方法,但是在 Apple 的私有框架中,CoreTelephony.framework有一种方法CTGetIMEI可以帮助您。

回答by bsneeze

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.

我敢肯定,您有很多原因无法轻松做到这一点。自动解锁应用程序?我不这么认为。我相信 Apple 和 AT&T 也不会太喜欢它。

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

*#06# 是手动获取的方式。

回答by Pedro Rom?o

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

我只在 stackoverflow 中搜索了此处,结论是 Apple 不再允许在 iOS 6 之后查找手机 EMEI。

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

您可以使用 UDID 识别设备。我在这里找到了答案https://stackoverflow.com/a/19927376/2283308

回答by Vanguarder

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

将头文件“CoreTelephony.h”添加到您的项目中

CoreTelephony.h

核心电话.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

现在,您可以轻松获得imei

    NSString *imei;
_CTServerConnectionCopyMobileIdentity(&result, sc, &imei);