self.centerCall = [[CTCallCenter alloc] init];
self.centerCall.callEventHandler = ^(CTCall * call){//TODO:检测到来电后的处理
NSLog(@"监听电话 :%@",call.callState);
};
CTCallCenter *callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler = ^(CTCall* call) {
if ([call.callState isEqualToString:CTCallStateDisconnected])
{
NSLog(@"Call has been disconnected");
}
else if ([call.callState isEqualToString:CTCallStateConnected])
{
NSLog(@"Call has just been connected");
}
else if([call.callState isEqualToString:CTCallStateIncoming])
{
NSLog(@"Call is incoming");
}
else if ([call.callState isEqualToString:CTCallStateDialing])
{
NSLog(@"call is dialing");
}
else
{
NSLog(@"Nothing is done");
}
};