-2

在使用应用程序时,我想阻止所有来电和短信。它至少应该在越狱的iphone上工作。我有这段代码可以阻止通话,但不能阻止短信 - 我该如何解决?

 importCoreTelephony/CoreTelephonyDefines.h>

 extern NSString const *kCTSMSMessageReceivedNotification; extern
 NSString const *kCTSMSMessageReplaceReceivedNotification; extern
 NSString const *kCTSIMSupportSIMStatusNotInserted; extern NSString
 const *kCTSIMSupportSIMStatusReady;

 typedef struct __CTCall CTCall; extern NSString
 CTCallCopyAddress(void, CTCall *);

 void * CTSMSMessageSend(id server,id msg); typedef struct
 __CTSMSMessage CTSMSMessage; NSString *CTSMSMessageCopyAddress(void *, CTSMSMessage *); NSString *CTSMSMessageCopyText(void *, CTSMSMessage
 *);

 int CTSMSMessageGetRecordIdentifier(void * msg); NSString *
 CTSIMSupportGetSIMStatus(); NSString *
 CTSIMSupportCopyMobileSubscriberIdentity();

 id CTSMSMessageCreate(void* unknow/always 0/,NSString*
 number,NSString* text); void * CTSMSMessageCreateReply(void*
 unknow/always 0/,void * forwardTo,NSString *text);

 id CTTelephonyCenterGetDefault(void); void
 CTTelephonyCenterAddObserver(id, id, CFNotificationCallback, NSString
 *, void ,int); void CTTelephonyCenterRemoveObserver(id,id,NSString,void*); int
 CTSMSMessageGetUnreadCount(void);

 void * CTCallDisconnect(CTCall *call);

 static void callback(CFNotificationCenterRef center, void *observer,
 CFStringRef name, const void *object, CFDictionaryRef userInfo) {

 NSString *notifyname = (__bridge NSString *)name;

 if ([notifyname
 isEqualToString:@"kCTCallIdentificationChangeNotification"]) {

     NSDictionary *info = (__bridge NSDictionary *)userInfo;

     CTCall *call = (__bridge CTCall *)[info objectForKey:@"kCTCall"];

     NSString *caller = CTCallCopyAddress(NULL, call);

     NSLog(@"RECEIVED CALL: %@", caller);

     CTCallDisconnect(call);

 } }

 static void signalHandler(int sigraised) {

 printf("\nInterrupted.\n"); exit(0); }

在 viewdidload 中:

 id ct = CTTelephonyCenterGetDefault();
 CTTelephonyCenterAddObserver(ct, NULL, callback, NULL, NULL,
 CFNotificationSuspensionBehaviorHold);

 sig_t oldHandler = signal(SIGINT, signalHandler); if (oldHandler ==
 SIG_ERR) {

 printf("Could not establish new signal handler"); exit(1); }

 printf("Starting run loop and watching for notification.\n");
 CFRunLoopRun();
4

1 回答 1

0

我认为您在以下行中犯了一些语法错误,请检查

      id CTSMSMessageCreate(void* unknow/*always 0*/,NSString* number,NSString* text);
void * CTSMSMessageCreateReply(void* unknow/*always 0*/,void * forwardTo,NSString *text);
于 2013-02-27T17:25:47.877 回答