2011-12-30 3 views
12

현재 메시지 내용에 따라 문자 메시지를 가로 채고 반응하는 응용 프로그램을 작성하려고합니다. CKSMSService 클래스의 _receivedMessage:(struct __CKSMSRecord *)message replace:(BOOL)replace 메서드에 연결하려고 시도했지만이 호출되지 않습니다.IOS 탈옥기 어떻게 SMS/문자 메시지를 가로 채기

누군가 내게 어떤 기능/수업을 들려 주어야할까요? 텍스트 메시지가 표시되고 데이터베이스에 저장되기 전에 텍스트 메시지를 가로 채야합니다. 나는 IOS 5.0.1에있다.

도움이된다면 정말 감사드립니다.

+0

이 질문에 관심이 있다면 [감옥 스택 Exchange 사이트]에 대한 51 지역 제안을지지하지 않는 이유는 무엇입니까? (http://area51.stackexchange.com/proposals/18154/ios-jailbreaking-development?referrer=EuWVi6IpN0_KzzEhC7I -Qw2) – rjstelling

답변

10

이 코드 스 니펫은 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); 
} 
+0

개인 헤더를 어떻게보고 클래스 덤프를합니까? – brianestey

+0

안녕하세요 @rajagp, 알림을받은 후 메시지를 차단하는 방법을 알고 계십니까? – RVN

+0

그렇게 할 수있는 대안이 있습니까? Coretelephony.h 헤더 파일을 사용하고 있습니다. 이 헤더를 사용하여 SMS 알림을 구현할 수 있습니까? –

1

포스터가 이미 rajagp's answer 가능하지만, 나는 그것이 문제가 실제로 무엇을 요구하지 않습니다 확실 해요 iOS 5에 입니다. iOS 5의 경우 메시지가 더 이상 표시되지 않지만 더 이상 메시지 이 표시되지 않습니다.

그래서, 내가 한 것은 kCTMessageReceivedNotification에 대한 rajagp의 알림 처리기이며 그 안에 SMS 데이터베이스의 use the code posted here to actually get the content of the text message입니다.

0

여전히 iOS 7에서 작동하지만 kCTMessageReceivedNotification 알림을받은 후 약간의 지연이 필요하다는 것을 알았습니다. 그렇지 않으면 방금받은 SMS를 놓치게됩니다. 나는 [self performSelector .. afterDelay : 0.1]와 함께 0.1 초의 지연을 사용한다.