1. import <CoreTelephony/CTCallCenter.h>
2. import <CoreTelephony/CTCall.h>
##@property(strong,nonatomic) CTCallCenter *callCenter; ##4、创建并接收回调等
_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");
}
};
1.Call is incoming
2. Call has just been connected
3.Call has been disconnected
1.call is dialing
2.Call has just been connected
3.Call has been disconnected