iphone使用private API 发送短信
http://www2.ooreport.com/ooReport/DocView.aspx?Id=OSJNOSJN000109
Add->Existing Frameworks...->PrivateFrameworks->选择私有框架
例一. 发送短信
到ericasadun.com网站找到需要的头文件代码,新建一个头文件,粘贴进去
#import此头文件,便可使用其中的类和方法了
CODE:
在项目中加入private framework:CoreTelephony.framework
创建头文件sms.h
从http://ericasadun.com/iPhoneDocs300/_c_t_message_center_8h-source.html复制头文件代码
CODE:
// CoreTelephony/CTMessageCenter.h
@interface CTMessageCenter : NSObject
{
}
+ (id)sharedMessageCenter;
- (id)init;
- (id)sendSMS:(id)fp8;
- (id)sendMMSFromData:(id)fp8 messageId:(unsigned int)fp12;
- (id)sendMMS:(id)fp8;
- (id)send:(id)fp8;
- (id)incomingMessageWithId:(unsigned int)fp8 telephonyCenter:( id)fp12 isDeferred:(BOOL)fp16;
- (int)incomingMessageCount;
- (id)allIncomingMessages;
- (void)acknowledgeIncomingMessageWithId:(unsigned int)fp8;
- (void)acknowledgeOutgoingMessageWithId:(unsigned int)fp8;
- (id)incomingMessageWithId:(unsigned int)fp8;
- (id)deferredMessageWithId:(unsigned int)fp8;
- (id)statusOfOutgoingMessages;
- (id)encodeMessage:(id)fp8;
- (id)decodeMessage:(id)fp8;
- (BOOL)isMmsEnabled;
- (BOOL)isMmsConfigured;
- (BOOL)sendSMSWithText:(id)fp8 serviceCenter:(id)fp12 toAddress:(id)fp16;
@end
CODE:
#import "sms.h"
例二. 获取IMEI
// 发送123到10086
[[CTMessageCenter sharedMessageCenter] sendSMSWithText:@"123" serviceCenter:nil toAddress:@"10086"];
CODE:
在项目中加入:Message.framework
创建头文件network.h
从http://ericasadun.com/iPhoneDocs300/_network_controller_8h-source.html复制头文件代码
CODE:
// Message/NetWorkController.h
@class NSString, NSTimer;
@interface NetworkController : NSObject
{
struct __SCDynamicStore *_store;
NSString *_domainName;
unsigned int _waitingForDialToFinish:1;
unsigned int _checkedNetwork:1;
unsigned int _isNetworkUp:1;
unsigned int _isFatPipe:1;
unsigned int _edgeRequested:1;
NSTimer *_notificationTimer;
}
+ (id)sharedInstance;
- (void)dealloc;
- (id)init;
- (BOOL)isNetworkUp;
- (BOOL)isFatPipe;
- (BOOL)inAirplaneMode;
- (id)domainName;
- (BOOL)isHostReachable:(id)fp8;
- (id)primaryEthernetAddressAsString;
- (id)IMEI;
- (id)edgeInterfaceName;
- (BOOL)isEdgeUp;
- (void)bringUpEdge;
- (void)keepEdgeUp;
- (void *)createPacketContextAssertionWithIdentifier:(id)fp8;
@end
CODE:
#import "network.h"
ios4.0发送短信:http://www.cnspirit.com/?p=138
// 获得IMEI
NetworkController *ntc = [NetworkController sharedInstance];
NSString *imeistring = [ntc IMEI];
// show IMEI
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your IMEI Is"
message:imeistring
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
上一篇: 盖茨:我不用iPhone 也不买比特币