阻止ios6上的短信 [英] Block sms on ios6

查看:192
本文介绍了阻止ios6上的短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个破牢的设备,我想阻止传入的消息。
我正在尝试挂钩_ingestIncomingCTMessage,但它没有结果(它似乎不适用于ios6)。我怎么能阻止ios6中的短信?

I'm building for a jail-broken device and I want to block incoming messages. I'm trying to hook _ingestIncomingCTMessage, but it has no result( it seems not working on ios6). How else I can block sms in ios6?

推荐答案

这非常棘手。苹果在这方面做出了重大改变。这在iOS 5上很容易,但在iOS 6上我找不到简单的方法。
首先,您需要使用CTTelephonyCenter观察__kIMChatItemsDidChangeNotification通知。我是在SpringBoard注入的dylib中做的。不确定,但这可能很重要。

This is quite tricky. Apple made major changes in this area. It's very easy on iOS 5 but on iOS 6 I couldn't find easy way to do it yet. First, you need to observer __kIMChatItemsDidChangeNotification notification using CTTelephonyCenter. I'm doing it in dylib injected in SpringBoard. Not sure but this may be important.

CTTelephonyCenterAddObserver(CTTelephonyCenterGetDefault(), NULL, Callback, NULL, NULL, CFNotificationSuspensionBehaviourHold);

void Callback(CFNotificationCenterRef, void*, NSString* notification, const void*, NSDictionary* userInfo)
{
    if (![notification isEqualToString:@"__kIMChatItemsDidChangeNotification"])
    {
        return;
    }

    for (IMChatItem* chatItem in userInfo[@"__kIMChatItemsKey"])
    {
        IMMessage* msg = [chatItem message];//Incoming message object
        NSString* text = [[msg text] string];//message text
        NSString* sender = [[msg sender] ID];//message sender

        [[IMDMessageStore sharedInstance] performBlock:^{
            IMDChatRecordDeleteChatForGUID([NSString stringWithFormat:@"SMS;-;%@", sender]);
        }];
    }
}

最后一位非常重要。你不能只删除邮件。您需要在特定的内部线程上执行此操作,否则您将收到错误。这就是我使用 IMDMessageStore 的原因。它是 performBlock:方法在这个特殊线程上执行块。
IMDChatRecordDeleteChatForGUID 函数可以在IMDPersistence.framework中找到。它删除具有特定GUID的整个消息树(聊天/对话)。我找不到一种方法来检索这个GUID,所以我使用来自SMS sqlite数据库的GUID手动构建它作为样本。

Last bit is very important. You can't just delete message. You need to do it on a specific internal thread or you'll get an error. This is why I'm using IMDMessageStore. It's performBlock: method executes block on this special thread. IMDChatRecordDeleteChatForGUID function can be found in IMDPersistence.framework. It deletes whole message tree (chat/conversation) with specific GUID. I couldn't find a way to retrive this GUID so I'm building it manually using GUIDs from SMS sqlite database as a sample.

要删除一条消息,你可以使用 IMDMessageRecordDeleteMessagesForGUIDs([NSArray arrayWithObject:[msg guid]]);

To delete just one message you can use IMDMessageRecordDeleteMessagesForGUIDs([NSArray arrayWithObject:[msg guid]]);

IMChatItem IMMessage 可以在 IMCore.framework 中找到。 IMDMessageStore 位于 IMDaemonCore.framework

IMChatItem and IMMessage can be found in IMCore.framework. IMDMessageStore is in IMDaemonCore.framework.

这是容易的部分。现在,当您收到消息并以此方式阻止它时,您将看到它仍然显示在MobileSMS应用程序中,您仍然可能会收到bullein通知,您仍然会获得徽章,告诉您有未读消息。但是,如果您打开SMS sqlite数据库,您将看到该消息确实被删除。阻止这些并不容易。

This is easy part. Now when you receive message and block it this way you will see that it still shows in MobileSMS app, you still might get bullein notification, you still get badge telling you there is unread message. But if you open SMS sqlite database you will see that message was indeed deleted. Blocking these is not that easy.


  1. Bullein。在SpringBoard中,您需要挂钩 BBServer 方法 publishBulletin:destinations:alwaysOnLockScreen:。第一个参数是BBBulletin对象。如果是传入消息公告,那么部分属性等于 com.apple.MobileSMS 。要阻止公告,只需从此方法返回,不要调用原始实现。

  2. MobileSMS应用徽章。 ChatKit.serviceBundle是在有传入短信时在SpringBoard中加载的。你需要在 MessagesBadgeController - _madridChatRegistered: _madridUnreadCountChanged:。他们的第一个参数是 NSNotification 对象与对象属性包含 IMChat 目的。再次,只需从这些方法返回以防止徽章更改。

  3. MobileSMS应用。为了阻止它显示已经删除的消息,我是
    挂钩了很多方法。我将给你列表:
    SMSApplication _receivedMessage: CKTranscriptController
    _messageReceived:
    CKConversationList _handleRegistryDidRegisterChatNotification:,_ handleRegistryDidLoadChatNotification:,hasActiveConversations,unreadCount CKConversationController
    _chatParticipantsChangedNotification:,updateConversationList
    CKMessagesController showConversation:animate:forceToTranscript:

  1. Bullein. In SpringBoard you need to hook BBServer method publishBulletin:destinations:alwaysOnLockScreen:. First argument is BBBulletin object. If it's incoming message bulletin it's section property equals com.apple.MobileSMS. To block bulletin just return from this method and don't call original implementation.
  2. MobileSMS app badge. There is ChatKit.serviceBundle that's being loaded in SpringBoard when there is incoming SMS. You need to hook two methods in MessagesBadgeController - _madridChatRegistered: and _madridUnreadCountChanged:. Their first argument is NSNotification object with object property containing IMChat object. Again, just return from these methods to prevent badge changes.
  3. MobileSMS app. To stop it from showing already deleted messages I'm hooking quite a lot of methods. I will just give you the list: SMSApplication _receivedMessage:, CKTranscriptController _messageReceived:, CKConversationList _handleRegistryDidRegisterChatNotification:, _handleRegistryDidLoadChatNotification:, hasActiveConversations, unreadCount. CKConversationController _chatParticipantsChangedNotification:, updateConversationList, CKMessagesController showConversation:animate:forceToTranscript:

关于ChatKit.serviceBundle。要挂钩它的类,你需要等待SpringBoard实际加载它。这是在 SBPluginManager loadPluginBundle:中完成的。 Bundle标识符应该等于 com.apple.SMSPlugin 。只有这样你才能挂钩方法。

About ChatKit.serviceBundle. To hook it's classes you need to wait when SpringBoard actually loads it. This is done in SBPluginManager loadPluginBundle:. Bundle identifier should be equal to com.apple.SMSPlugin. Only then you can hook methods.

就是这样。相当多的工作,但它工作得很好 - 没有传入消息的迹象,即使你在消息到达时在MobileSMS应用程序中。

That's it. Quite a lot of work but it's working perfectly - no sign of incoming message, even if you were in MobileSMS application when message arrived.

我确信有更简单的方法可以做到这一点。 com.apple.imagent守护程序向各种iOS组件发送通知。这在iOS 6消息传递系统中非常重要。好的起点。

I'm sure there is easier way to do it. There is com.apple.imagent daemon which sends notifications to various iOS components. It's very important in iOS 6 messaging system. Good place to start.

这篇关于阻止ios6上的短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆