我尝试使用CTCallCenter接收来自iPhone的来电。当应用程序处于活动状态时,我会调用设备,并且不会调用callEventHandler。
可能是什么原因?
我在iPhone 5和XCode7上安装了IOS9.0 beta3。
我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
CTCallCenter *callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler = ^(CTCall* call)
{
if (call.callState == CTCallStateDisconnected)
{
NSLog(@"Call has been disconnected");
[self ShowMessage:@"Call has been disconnected"];
}
else if (call.callState == CTCallStateConnected)
{
NSLog(@"Call has just been connected");
[self ShowMessage:@"Call has just been connected"];
}
else if(call.callState == CTCallStateIncoming)
{
NSLog(@"Call is incoming");
[self ShowMessage:@"Call is incoming"];
}
else
{
NSLog(@"None of the conditions");
[self ShowMessage:@"None of the conditions"];
}
};
}