#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCall.h>
_callCenter = [[CTCallCenter alloc] init];
__weak typeof(self) weak_self = self;
_callCenter.callEventHandler = ^(CTCall * _Nonnull call) {
if ([call.callState isEqualToString:CTCallStateDisconnected])
{
NSLog(@"挂断电话Call has been disconnected");
weak_self.handleCall = NO;
}
else if ([call.callState isEqualToString:CTCallStateConnected])
{
weak_self.handleCall = YES;
NSLog(@"电话通了Call has just been connected");
}
else if([call.callState isEqualToString:CTCallStateIncoming])
{
NSLog(@"来电话了Call is incoming");
weak_self.handleCall = YES;
}
else if ([call.callState isEqualToString:CTCallStateDialing])
{
weak_self.handleCall = YES;
NSLog(@"正在拨出电话call is dialing");
}
else
{
NSLog(@"什么没做Nothing is done");
weak_self.handleCall = NO;
}
};
网友评论