美文网首页
ios监测来电

ios监测来电

作者: 今年27 | 来源:发表于2018-08-21 18:07 被阅读12次
    #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;
            }
            
        };
    

    相关文章

      网友评论

          本文标题:ios监测来电

          本文链接:https://www.haomeiwen.com/subject/smgjiftx.html