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