标签:
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCall.h>
@property(nonatomic,strong)CTCallCenter *callCenter;
以下代码写在didFinishLaunchingWithOptions中。
必须将callCenter声明为成为变量,否则无法监听。
self.callCenter = [[CTCallCenter alloc] init];
self.callCenter.callEventHandler = ^(CTCall* call) {
if ([call.callState isEqualToString:CTCallStateDisconnected])
{
NSLog(@"Call has been disconnected");
}
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");
}
};
标签:
原文地址:http://www.cnblogs.com/dandan4164/p/5541365.html