iPhone开发技巧之私有API(1) --- 设备相关信息
2011-05-17 21:40
471 查看
在iPhone开发技巧之环境篇(8)--- 使用非公开的API一章中我们已经学会了怎样得到非公开PAI头文件的方法。这里将手头收集到的各种应用方法做一个总结,希望对您 有所帮助。
使用这些API是要冒一些风险的,一是不会通过 App Stroe 的审核,二是以后比一定还能在高版本的SDK中使用。所以使用之前,三思而行。
先总结一些与设备相关的API。
使用这些API是要冒一些风险的,一是不会通过 App Stroe 的审核,二是以后比一定还能在高版本的SDK中使用。所以使用之前,三思而行。
先总结一些与设备相关的API。
IMEI
可以在这里下载NetworkController.h, 或者使用你自己dump的版本。使用如下:1 2 3 4 5 6 7 8 | #import "NetworkController.h" // 获得IMEI // 需要 Message.framework + (NSString*) getDeviceIMEI { NetworkController *ntc = [NetworkController sharedInstance]; return [ntc IMEI]; } |
IMSI
1 2 3 4 5 6 7 | // 需要 CoreTelephony framework // 在文件开头加入 extern NSString* CTSIMSupportCopyMobileSubscriberIdentity(); + (NSString*) getDeviceIMSI { return CTSIMSupportCopyMobileSubscriberIdentity(); } |
本机电话号码
1 2 3 4 5 6 7 | // 需要 CoreTelephony framework // 在文件开头加入 extern NSString* CTSettingCopyMyPhoneNumber(); + (NSString*) getPhoneCodeByCT { return CTSettingCopyMyPhoneNumber(); } |
动态加载Framework
除了使用Xcode将Framework加入工程,你也可以使用下面的方法,在程序中动态加载,比如取得IMEI的例子:1 2 3 4 5 6 7 | NSString* sdk_path = @"/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IPHONE_SDK}.sdk/System/Library/PrivateFrameworks"; NSBundle *b = [NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/Message.framework", sdk_path]]; if ([b load]) { Class NetworkController = NSClassFromString(@"NetworkController"); id nc = [NetworkController sharedInstance]; NSLog(@"-- IMEI: %@", [nc IMEI]); } |
相关文章推荐
- iPhone开发技巧之私有API — 设备相关信息
- iPhone开发技巧之私有API — 设备相关信息
- 转:iPhone开发技巧之私有API(1) — 设备相关信息
- iPhone开发技巧之私有API --- 设备相关信息
- iPhone开发技巧之私有API(4)--- UIBarButtonItem
- iPhone开发技巧之私有API--- 设置UIWebView中的User-Agent
- iPhone开发技巧之私有API(4)— UIBarButtonItem
- iPhone开发技巧之私有API(5)--- UISegmentedControl
- iPhone开发技巧之私有API--- 用UIWebView访问BASIC认证的页面
- iPhone开发技巧之私有API(6)--- 设置UIWebView中的User-Agent
- iPhone开发技巧之私有API(6)--- 设置UIWebView中的User-Agent
- iPhone开发技巧之私有API--- UIApplication
- iPhone开发技巧之私有API--- UIBarButtonItem
- iPhone开发技巧之私有API(7)--- 用UIWebView访问BASIC认证的页面
- iPhone开发技巧之私有API--- UIBarButtonItem
- iPhone开发技巧之私有API(8)--- UIApplication
- iPhone开发技巧之私有API(3)--- UIButton
- iPhone开发技巧之私有API(2)— UITableView
- iPhone开发技巧之私有API--- UIBarButtonItem
- iPhone开发技巧之私有API(2)--- UITableView