4、iOS监听通话状态

监听通话状态

#import 
#import 

self.callCenter = [[CTCallCenteralloc] init];
        WEAKSELF;
        self.callCenter.callEventHandler = ^(CTCall* call) {
            NSLog(@"callid %@",call.callID);
            if ([call.callState isEqualToString:CTCallStateDisconnected])
            {
                NSLog(@"挂断了电话咯Call has been disconnected");
                if(weakSelf.isTrueCall && weakSelf.currentContactPhoneOrder && weakSelf.isContactSuccess){
                    [weakSelf notificationServicePhoneState];
                }else{
                    weakSelf.isTrueCall = NO;
                    weakSelf.isContactSuccess = NO;
                }
            }
            else if ([call.callState isEqualToString:CTCallStateConnected])
            {
                NSLog(@"电话通了Call has just been connected");
                if (weakSelf.isTrueCall) {
                    weakSelf.isContactSuccess = YES;
                }
            }
            else if([call.callState isEqualToString:CTCallStateIncoming])
            {
                NSLog(@"来电话了Call is incoming");

            }
            else if ([call.callState isEqualToString:CTCallStateDialing])
            {
                NSLog(@"正在播出电话call is dialing");
                weakSelf.isTrueCall = YES;
            }
            else
            {
                NSLog(@"嘛都没做Nothing is done");
            }
        };

你可能感兴趣的:(4、iOS监听通话状态)