IOS越狱如何拦截短信/短信

我目前正在尝试编写拦截短信的应用程序,并根据该消息的内容作出反应。 我试图挂钩到_receivedMessage:(struct __CKSMSRecord *)message replace:(BOOL)replace CKSMSService类中的_receivedMessage:(struct __CKSMSRecord *)message replace:(BOOL)replace方法,但这似乎并没有被调用。

有人能告诉我什么function/类我必须挂钩? 我需要拦截文本消息,然后显示并存储到数据库中。 我在IOS 5.0.1上。

任何帮助是真正的赞赏。

此代码段应拦截短信 – 您可以扩展它的其他types的通知。 也可以在iOS 5.0.1上运行。 虽然不用iMessages。 链接与CoreTelephony框架(有一堆私人标题,你可以类转储)

 #include <dlfcn.h> #define CORETELPATH "/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony" id(*CTTelephonyCenterGetDefault)(); void (*CTTelephonyCenterAddObserver) (id,id,CFNotificationCallback,NSString*,void*,int); static void telephonyEventCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { NSString *notifyname=(NSString *)name; if ([notifyname isEqualToString:@"kCTMessageReceivedNotification"])//received SMS { NSLog(@" SMS Notification Received :kCTMessageReceivedNotification"); // Do blocking here. } } -(void) registerCallback { void *handle = dlopen(CORETELPATH, RTLD_LAZY); CTTelephonyCenterGetDefault = dlsym(handle, "CTTelephonyCenterGetDefault"); CTTelephonyCenterAddObserver = dlsym(handle,"CTTelephonyCenterAddObserver"); dlclose(handle); id ct = CTTelephonyCenterGetDefault(); CTTelephonyCenterAddObserver( ct, NULL, telephonyEventCallback, NULL, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); } 

尽pipe海报已经接受了rajagp的回答 ,但是我很确定它不会在iOS 5上做实际问题。 对于iOS 5,我不再看到邮件内容 ,虽然我得到通知有一个新的消息。

所以,我所做的就是使用rajagp的kCTMessageReceivedNotification通知处理程序,并在其中使用此处发布的代码实际从SMS数据库获取文本消息的内容 。

这仍然适用于iOS 7,但我发现在收到kCTMessageReceivedNotification通知后需要稍微延迟。 否则你会错过刚刚收到的短信。 我使用了一个0.1秒的延迟,[self performSelector .. afterDelay:0.1];

Interesting Posts