使用核心电话捕获传入的Callevent?

我想创build一个越狱iphone(ios 4.0或更高)的应用程序。 我希望我的应用程序保持运行状态,每当我的手机开始响铃(对于来电),我的应用程序应该能够捕捉到“呼入”事件,并基于此,我可以执行一些function,例如较低的扬声器音量。

任何人都可以指导我正确的方向,至于如何捕获这样的事件,或者如果它是在私有核心框架中可用?

你确定要监听电话而不使用吗?

- (void)applicationWillResignActive:(UIApplication *)application { /* Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. */ } 

哪个是默认的XCode4模板?

如果您仍然需要通话监控function,则可以在iOS 4+上的Core Telephony的公共部分中find

 #import <CoreTelephony/CTCall.h> #import <CoreTelephony/CTCallCenter.h> .... CTCallCenter *callCenter;//make it ivar if you are using ARC or handler will be auto-released .. callCenter = [[CTCallCenter alloc] init]; callCenter.callEventHandler=^(CTCall* call) { NSLog(@"Call id:%@", call.callID); [self callStateChange:call.callState andId:call.callID]; if (call.callState==CTCallStateDialing) { NSLog(@"Call state:dialing"); } if (call.callState==CTCallStateIncoming) { NSLog(@"Call state:incoming"); //here you lower your speaking volume if you want } if (call.callState==CTCallStateConnected) { NSLog(@"Call state:connected"); } if (call.callState==CTCallStateDisconnected) { NSLog(@"Call state:disconnected"); } };