问题
I searched SO before asking this question , there is no answers satisfying my needs.
So this is my requirement ,
I have this piece of code for detecting the incoming SMS , but it does not say how to dump these messages. I have successfully blocked the incoming calls but for messages i am not sure how to do this. any help here would be very much appreciated.
I am ok in using any private APIs.
if ([notifyname isEqualToString:@"kCTSMSMessageReceivedNotification"])
{
if ([[(NSDictionary *)userInfo allKeys]
containsObject:@"kCTSMSMessage"]) // SMS Message
{
CTSMSMessage *message = (CTSMSMessage *)
[(NSDictionary *)userInfo objectForKey:@"kCTSMSMessage"];
NSString *address = CTSMSMessageCopyAddress(NULL, message);
NSString *text = CTSMSMessageCopyText(NULL, message);
//NSArray *lines = [text componentsSeparatedByString:@"\n"];
printf(" %s %s\n", [address UTF8String],[text UTF8String]);
//printf(" %s\n", [text cString]);
fflush(stdout);
}
}
else if ([notifyname isEqualToString:@"kCTMessageReceivedNotification"])//received SMS
{
/*
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];
id incMsgPart = [[incMsg items] objectAtIndex:0];
NSData *smsData = [incMsgPart data];
NSString *smsText = [[NSString alloc] initWithData:smsData encoding:NSUTF8StringEncoding];
}
*/
}
Thanks Naveen
回答1:
You're question isn't clear enough. Do you want them to be dropped completely so they won't even be in the Message App (and the database) or do you just want SpringBoard to not notify the user of an incoming message?
For the first one you will have to hook the process which actually sends out that notification which you are listening to in your code sniplet. I'm pretty sure that you'll have to tinker with imagent (/System/Library/PrivateFrameworks/IMCore.framework/imagent.app/imagent).
For the second one you'll have to play around in SpringBoard. Since iOS 5.0 BulletinBoard is handling the notifications to the user, so you could block it there. (You probably wanna check out the SMSBBPlugin which is a BulletinBoard plugin).
Or just fire up your disassembler of choice and see how tweaks like biteSMS are doing it ;)
Keep in mind that jailbreak tweak development sometimes requires a lot of reversing and tinkering and most people will keep huge parts of their findings to themselves.
来源:https://stackoverflow.com/questions/10122998/how-to-block-incoming-sms-in-iphone-jailbreak-code