1

我必须在通话结束时获得通话状态,但我的事件没有被调用,就像行总是返回 false

[callCenter setCallEventHandler: ^(CTCall* call)

这是我的代码

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");
    }

};

任何帮助将不胜感激

4

1 回答 1

1

你的代码看起来不错;但是,如果您的应用在调用事件期间暂停,则不会调用您的事件处理程序。

来源:CTCallCenter 类参考

如果您的应用程序在调用事件发生时处于活动状态,则系统会立即将该事件分派给您的处理程序。但是,调用事件也可能在您的应用程序暂停时发生。当它被挂起时,您的应用程序不会收到呼叫事件。当您的应用程序恢复活动状态时,它会为每个更改状态的调用接收一个调用事件 - 无论您的应用程序暂停时调用经历了多少状态更改。当您的应用程序返回活动状态时,发送到您的处理程序的单个调用事件描述了当时调用的状态。

于 2012-09-28T15:04:12.427 回答