需求是这样:截获到短信后,不将短信存入到系统收件箱。
我现在只能做到截获短信,但是,如果不存入到系统收件箱还没有思路,望路过的诸位老大指点。
截获短信的代码如下:else if ([notifyname isEqualToString:@"kCTMessageReceivedNotification"]) //收到短信
{
/*
kCTMessageIdKey = "-2147483636";
kCTMessageTypeKey = 1;
*/
NSDictionary *info = (NSDictionary *)userInfo;
CFNumberRef msgID = (CFNumberRef)[info objectForKey:@"kCTMessageIdKey"];
int result;
CFNumberGetValue((CFNumberRef)msgID, kCFNumberSInt32Type, &result);
Class CTMessageCenter = NSClassFromString(@"CTMessageCenter");
id mc = [CTMessageCenter sharedMessageCenter];
id incMsg = [mc incomingMessageWithId: result];
int msgType = (int)[incMsg messageType];
if (msgType == 1) //experimentally detected number
{
id phonenumber = [incMsg sender];
NSString *senderNumber = (NSString *)[phonenumber canonicalFormat];
NSLog(@"senderNumber is: %@ *************************",senderNumber);
id incMsgPart = [[incMsg items] objectAtIndex:0];
NSData *smsData = [incMsgPart data];
NSString *smsText = [[NSString alloc] initWithData:smsData encoding:NSUTF8StringEncoding];
NSLog(@"smsText is: %@ *************************",smsText);
}
}
我现在只能做到截获短信,但是,如果不存入到系统收件箱还没有思路,望路过的诸位老大指点。
截获短信的代码如下:else if ([notifyname isEqualToString:@"kCTMessageReceivedNotification"]) //收到短信
{
/*
kCTMessageIdKey = "-2147483636";
kCTMessageTypeKey = 1;
*/
NSDictionary *info = (NSDictionary *)userInfo;
CFNumberRef msgID = (CFNumberRef)[info objectForKey:@"kCTMessageIdKey"];
int result;
CFNumberGetValue((CFNumberRef)msgID, kCFNumberSInt32Type, &result);
Class CTMessageCenter = NSClassFromString(@"CTMessageCenter");
id mc = [CTMessageCenter sharedMessageCenter];
id incMsg = [mc incomingMessageWithId: result];
int msgType = (int)[incMsg messageType];
if (msgType == 1) //experimentally detected number
{
id phonenumber = [incMsg sender];
NSString *senderNumber = (NSString *)[phonenumber canonicalFormat];
NSLog(@"senderNumber is: %@ *************************",senderNumber);
id incMsgPart = [[incMsg items] objectAtIndex:0];
NSData *smsData = [incMsgPart data];
NSString *smsText = [[NSString alloc] initWithData:smsData encoding:NSUTF8StringEncoding];
NSLog(@"smsText is: %@ *************************",smsText);
}
}
解决方案 »
- iphone客户端小项目外包,有意请入
- IPhone 音频口通信?
- 请教MPMoviePlayerViewController相关
- ios PopoverView presentPopoverFromRect 在弹出视图里如何取得每个cell的按钮坐标
- IOS 如何返回一个泛型数据啊
- opencv for mac 无法安装,大家帮我看看步骤错在哪里?
- 怎么根据每个像素点的(R,G,B)值生成UIImage
- iphone开发中数据存储 属性列表,归档,SQLite3,core data 还有FMDB应该选择哪种?
- java 接收ios NSData数据 读取不到
- GCDAsyncSocket读取流被关闭的问题
- mac 上自带的归档实用工具在哪
- 内存释放问题,求解.
操作数据库首先要确保系统等其它进程不占有
还要……程序要突破沙盒限制而不被Apple拒……我看还是找找API看看吧
(没做过,瞎说的)