Intercepting a phone call - iPhone (the correct method for connecting to CoreTelephony)

I am new to jailbreak trick development scenario. I am trying to find a suitable method for "intercepting" so that I can intercept an incoming call (and then run some code).

I deleted the header files in the CoreTelephony structure, however, no methods seem obvious. I tried:

- (void)broadcastCallStateChangesIfNeededWithFailureLogMessage:(id)arg1; - (BOOL)setUpServerConnection; 

but they did not work. After working, I mean - it is called when the iPhone receives a call.

Any pointers to a suitable method to intercept? Thanks:)

Note: This will be a jailbreak trick using private APIs, so it will not be sent to the App Store.

+3
source share
1 answer

I have not tested your code, but I think that your problem may be that you need to use the Core Telephony notification center to register for this event (not what you had in the code in your comment). Something like that:

 // register for all Core Telephony notifications id ct = CTTelephonyCenterGetDefault(); CTTelephonyCenterAddObserver(ct, // center NULL, // observer telephonyEventCallback, // callback NULL, // event name (or all) NULL, // object CFNotificationSuspensionBehaviorDeliverImmediately); 

and your callback function

 static void telephonyEventCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { NSString *notifyname = (NSString*)name; if ([notifyname isEqualToString:@"kCTCallIdentificationChangeNotification"]) { NSDictionary* info = (NSDictionary*)userInfo; CTCall* call = (CTCall*)[info objectForKey:@"kCTCall"]; NSString* caller = CTCallCopyAddress(NULL, call); if (call.callState == CTCallStateDisconnected) { NSLog(@"Call has been disconnected"); } else if (call.callState == CTCallStateConnected) { NSLog(@"Call has just been connected"); } else if (call.callState == CTCallStateIncoming) { NSLog(@"Call is incoming"); } else if (call.callState == CTCallStateDialing) { NSLog(@"Call is Dialing"); } else { NSLog(@"None of the conditions"); } } } 

I suggest another method in this similar question here . Also, pay attention to my comment in this question about not receiving notifications in UIApplication that were placed in the background.

Update: see cud_programmer's comment below about using kCTCallStatus in iOS 6 instead of kCTCall .

+2
source

All Articles