我目前正在嘗試編寫攔截短信的應用程序,並根據該消息的內容作出反應。 我試圖掛鉤到CKSMSService類中的_receivedMessage:(struct __CKSMSRecord *)message replace:(BOOL)replace
方法,但這似乎根本不會被調用。IOS越獄如何攔截短信/短信
有人可以告訴我什麼函數/類我必須掛鉤嗎?我需要在文本消息顯示並存儲到數據庫之前攔截它。我在IOS 5.0.1上。
任何幫助是真正的讚賞。
我目前正在嘗試編寫攔截短信的應用程序,並根據該消息的內容作出反應。 我試圖掛鉤到CKSMSService類中的_receivedMessage:(struct __CKSMSRecord *)message replace:(BOOL)replace
方法,但這似乎根本不會被調用。IOS越獄如何攔截短信/短信
有人可以告訴我什麼函數/類我必須掛鉤嗎?我需要在文本消息顯示並存儲到數據庫之前攔截它。我在IOS 5.0.1上。
任何幫助是真正的讚賞。
此代碼段應攔截SMS消息 - 您可以將其擴展爲其他類型的通知。也可以在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);
}
你如何看到私有頭文件和類轉儲它們? – brianestey 2012-03-09 08:29:17
嗨@rajagp,你知道如何阻止收到通知後的消息? – RVN 2012-04-19 11:55:57
有沒有其他辦法可以做到這一點。我正在使用Coretelephony.h頭文件。我可以使用此標頭實施短信通知嗎? – 2014-06-23 07:35:18
雖然海報已經接受rajagp's answer,我敢肯定它不會做什麼的問題居然問,iOS 5上的。對於iOS 5,我不再看到消息內容了,但我確實收到通知有新消息。
所以,我所做的是採取rajagp的通知處理程序kCTMessageReceivedNotification
,和裏面,use the code posted here to actually get the content of the text message,從SMS數據庫。
這仍然適用於iOS 7,但我發現在收到kCTMessageReceivedNotification通知後需要略微延遲。否則你會錯過剛收到的短信。我使用0.1秒的延遲,[self performSelector .. afterDelay:0.1];
如果你的興趣在這個問題爲什麼不支持的[監獄破堆棧Exchange站點] 51區的提案(http://area51.stackexchange.com/proposals/18154/ios-jailbreaking-development?referrer=EuWVi6IpN0_KzzEhC7I -Qw2) – rjstelling 2012-01-02 14:19:06