使用私有API获取IMEI 手机发短信

使用private framework的一般方法为:
  1. Add->Existing Frameworks...->PrivateFrameworks->选择私有框架
  2. 到ericasadun.com网站找到需要的头文件代码,新建一个头文件,粘贴进去
  3. #import此头文件,便可使用其中的类和方法了
复制代码
例一. 发送短信
  1. 在项目中加入private framework:CoreTelephony.framework
  2. 创建头文件sms.h
  3. 从http://ericasadun.com/iPhoneDocs300/_c_t_message_center_8h-source.html复制头文件代码
复制代码
  1. // CoreTelephony/CTMessageCenter.h
  2. @interface CTMessageCenter : NSObject
  3. {
  4. }

  5. + (id)sharedMessageCenter;
  6. - (id)init;
  7. - (id)sendSMS:(id)fp8;
  8. - (id)sendMMSFromData:(id)fp8 messageId:(unsigned int)fp12;
  9. - (id)sendMMS:(id)fp8;
  10. - (id)send:(id)fp8;
  11. - (id)incomingMessageWithId:(unsigned int)fp8 telephonyCenter:( id)fp12 isDeferred:(BOOL)fp16;
  12. - (int)incomingMessageCount;
  13. - (id)allIncomingMessages;
  14. - (void)acknowledgeIncomingMessageWithId:(unsigned int)fp8;
  15. - (void)acknowledgeOutgoingMessageWithId:(unsigned int)fp8;
  16. - (id)incomingMessageWithId:(unsigned int)fp8;
  17. - (id)deferredMessageWithId:(unsigned int)fp8;
  18. - (id)statusOfOutgoingMessages;
  19. - (id)encodeMessage:(id)fp8;
  20. - (id)decodeMessage:(id)fp8;
  21. - (BOOL)isMmsEnabled;
  22. - (BOOL)isMmsConfigured;
  23. - (BOOL)sendSMSWithText:(id)fp8 serviceCenter:(id)fp12 toAddress:(id)fp16;

  24. @end
复制代码
  1. #import "sms.h"
  2. // 发送123到10086
  3. [[CTMessageCenter sharedMessageCenter] sendSMSWithText:@"123" serviceCenter:nil toAddress:@"10086"];  
复制代码
例二. 获取IMEI
  1. 在项目中加入:Message.framework
  2. 创建头文件network.h
  3. 从http://ericasadun.com/iPhoneDocs300/_network_controller_8h-source.html复制头文件代码
复制代码
  1. // Message/NetWorkController.h

  2. @class NSString, NSTimer;
  3. @interface NetworkController : NSObject
  4. {
  5.         struct __SCDynamicStore *_store;
  6.         NSString *_domainName;
  7.         unsigned int _waitingForDialToFinish:1;
  8.         unsigned int _checkedNetwork:1;
  9.         unsigned int _isNetworkUp:1;
  10.         unsigned int _isFatPipe:1;
  11.         unsigned int _edgeRequested:1;
  12.         NSTimer *_notificationTimer;
  13. }

  14. + (id)sharedInstance;
  15. - (void)dealloc;
  16. - (id)init;
  17. - (BOOL)isNetworkUp;
  18. - (BOOL)isFatPipe;
  19. - (BOOL)inAirplaneMode;
  20. - (id)domainName;
  21. - (BOOL)isHostReachable:(id)fp8;
  22. - (id)primaryEthernetAddressAsString;
  23. - (id)IMEI;
  24. - (id)edgeInterfaceName;
  25. - (BOOL)isEdgeUp;
  26. - (void)bringUpEdge;
  27. - (void)keepEdgeUp;
  28. - (void *)createPacketContextAssertionWithIdentifier:(id)fp8;

  29. @end
复制代码
  1. #import "network.h"
  2. // 获得IMEI
  3. NetworkController *ntc = [NetworkController sharedInstance];
  4. NSString *imeistring = [ntc IMEI];
  5. // show IMEI
  6. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your IMEI Is"
  7.                      message:imeistring 
  8.                      delegate:nil 
  9.                      cancelButtonTitle:@"OK" 
  10.                      otherButtonTitles:nil];
  11. [alert show];
  12. [alert release];
复制代码

getIMEI.png (18.68 KB)

你可能感兴趣的:(使用私有API获取IMEI 手机发短信)