1、
_callCenter = [[CTCallCenter alloc] init];
// CTCallCenter *callCenter = [CTCallCenter new];
__weak typeof(self) weakSelf = self;
_callCenter.callEventHandler = ^(CTCall *call){
if ([call.callState isEqualToString:CTCallStateDisconnected]){
NSLog(@"Call has been disconnected");
if (!weakSelf.isManualStopPlayzz)
[weakSelf play];
}
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");
}
};
ios9.2 需要设置Required background modes -- App provides Voice over IP services
2、监听 AVAudioSessionInterruptionNotification