使用CoreTelephony在iPhone上获取IMEI? [英] get IMEI on iPhone with CoreTelephony?
本文介绍了使用CoreTelephony在iPhone上获取IMEI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已尝试接受
的答案如何在iPhone上获取IMEI ?
但我得到一个空字符串。
I have tried the accepted answer of How to get IMEI on iPhone? but I got an empty string.
我看到有人建议使用CoreTelephony框架,
但我不知道怎么做用它来获取IMEI。
I saw somebody suggested to use CoreTelephony framework, but I am not sure how to use it to obtain the IMEI.
关于如何使用这个私有API的任何建议?
Any suggestion on how to use this private API?
推荐答案
注意:这不再适用了!
尚未在任何新iOS上测试过。
您必须将CoreTelephony.h添加到您的项目中。
确保标题有
You have to add CoreTelephony.h to your project. Make sure the header has
int * _CTServerConnectionCopyMobileEquipmentInfo (
struct CTResult * Status,
struct __CTServerConnection * Connection,
CFMutableDictionaryRef * Dictionary
);
然后你可以尝试这段代码:
Then you can try this code:
#import "CoreTelephony.h"
void getImei() {
struct CTResult it;
CFMutableDictionaryRef kCTDict;
conn = _CTServerConnectionCreate(kCFAllocatorDefault, ConnectionCallback,NULL);
_CTServerConnectionCopyMobileEquipmentInfo(&it, conn, &kCTDict);
NSLog (@ "kCTDict is %@", kCTDict);
CFStringRef meid = CFDictionaryGetValue(kCTDict, CFSTR("kCTMobileEquipmentInfoMEID"));
NSLog (@ "kCTMobileEquipmentInfoMEID is %@", meid);
CFStringRef mobileId = CFDictionaryGetValue(kCTDict, CFSTR("kCTMobileEquipmentInfoCurrentMobileId"));
NSLog (@ "kCTMobileEquipmentInfoCurrentMobileId is %@", mobileId);
}
你可以查看我的示例项目。
注意:我不认为代码在模拟器上运行,您的应用可能会被拒绝。
Note: I don't think the code works on the simulator and your app might get rejected.
这篇关于使用CoreTelephony在iPhone上获取IMEI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文