监听电话来时候的一些状态

#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCall.h>

/// 监听拨打电话状态
    _callCenter = [[CTCallCenter alloc] init];
    _callCenter.callEventHandler=^(CTCall* call)
    {
        if (call.callState == CTCallStateDisconnected)
        {
            NSLog(@"挂断电话");
            
        }
        else if (call.callState == CTCallStateConnected)
        {
            NSLog(@"电话刚连接通");
        }
        else if(call.callState == CTCallStateIncoming)
        {
            NSLog(@"有电话打进来");
            
        }
        else if (call.callState ==CTCallStateDialing)
        {
            NSLog(@"拨打电话");
        }
        else
        {
            NSLog(@"Nothing is done");
        }
    };

 

你可能感兴趣的:(监听电话来时候的一些状态)