4

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

RVN
  • 4,157
  • 5
  • 32
  • 35

1 Answers1

2

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.

YllierDev
  • 571
  • 4
  • 16
  • Hi @YllierDev, I am looking for the first one, for the selected number i want to reject the SMS completely. Can you please give me more info of how to Hook to the process or any link which explains the same. And you are right most of them do not disclose there findings :) – RVN Apr 28 '12 at 07:42
  • I don't have any experience with imagent. You will have to use MobileSubstrate to override methods or functions. http://iphonedevwiki.net/index.php/MobileSubstrate If you don't know how to write tweaks for MobileSubstrate, just google for it. There are tons of little tutorials out there. It's probably best to make dumping the headers your first step. Dump the headers of imagent and the associated private frameworks. Also, you'll probably need some knowledge in reversing. – YllierDev Apr 28 '12 at 14:46