Вы уверены, что хотите отслеживать звонки и не использовать
- (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 по умолчанию?
Если вам все еще нужен мониторинг вызовов - он доступен в публичной части Core Telephony на iOS 4 +
#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");
}
};