简体   繁体   English

如何在iPhone越狱+代码中阻止传入的短信

[英]How to block incoming SMS in iPhone jailbreak + code

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. 我有这段代码可以检测传入的SMS,但是没有说明如何转储这些消息。 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. 我可以使用任何私有API。

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 谢谢纳文

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? 您是否希望将它们完全删除,以使它们甚至不在Message App(和数据库)中,还是只希望SpringBoard不将传入消息通知用户?

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). 我很确定您必须修补图像(/System/Library/PrivateFrameworks/IMCore.framework/imagent.app/imagent)。

For the second one you'll have to play around in SpringBoard. 对于第二个,您必须在SpringBoard中玩转。 Since iOS 5.0 BulletinBoard is handling the notifications to the user, so you could block it there. 由于iOS 5.0 BulletinBoard正在处理向用户的通知,因此您可以在此处阻止它。 (You probably wanna check out the SMSBBPlugin which is a BulletinBoard plugin). (您可能想查看SMSBBPlugin,它是BulletinBoard插件)。

Or just fire up your disassembler of choice and see how tweaks like biteSMS are doing it ;) 或者只是启动您选择的反汇编程序,然后查看biteSMS之类的调整是如何进行的;)

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. 请记住,越狱调整的开发有时需要进行大量逆转和修改,大多数人会将发现的大部分内容保留给自己。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM