2012-09-28 59 views
1

我得在通话结束通话状态不会被调用,但我的事件,则不会调用下面像线总是返回falseCallEventhandler目标C

[呼叫中心setCallEventHandler:^(CTCall *调用)

这里是我的代码

CTCallCenter *callCenter = [[CTCallCenter alloc] init]; 
callCenter.callEventHandler=^(CTCall* call) 
{ 

    if(call.callState == CTCallStateDialing) 
    { 
     //The call state, before connection is established, when the user initiates the call. 
     NSLog(@"Call is dailing"); 
    } 
    if(call.callState == CTCallStateIncoming) 
    { 
     //The call state, before connection is established, when a call is incoming but not yet answered by the user. 
     NSLog(@"Call is Coming"); 
    } 

    if(call.callState == CTCallStateConnected) 
    { 
     //The call state when the call is fully established for all parties involved. 
     NSLog(@"Call Connected"); 
    } 

    if(call.callState == CTCallStateDisconnected) 
    { 
     //The call state Ended. 
     NSLog(@"Call Ended"); 
    } 

}; 

任何帮助将大大appriciated

回答

1

您的代码看起来不错;但是,如果您的应用在通话事件中被暂停,您的事件处理程序将不会被调用。

来源:CTCallCenter Class Reference

如果您的应用程序被激活时调用的事件发生时, 系统立即调度事件的处理程序。但是,拨打 事件也可能在您的应用程序暂停时发生。虽然 它已暂停,但您的应用程序不会收到通话事件。当 您的应用程序恢复活动状态时,它将为每次更改状态的呼叫接收单个呼叫 事件 - 无论有多少状态 更改您的应用程序暂停时遇到的呼叫。当您的应用程序 返回到活动状态时,将发送到您的处理程序的单个呼叫事件描述呼叫在该时间的状态。