Hi,
I wish to detect the call state after my app resumes the active state from the background. Im using the following piece of code for this:
CTCallCenter *callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler=^(CTCall* call)
{
if (call.callState == CTCallStateDisconnected)
{
NSLog(@"Call has been disconnected");
}
else if (call.callState == CTCallStateConnected)
{
NSLog(@"Call has just been connected");
}
else if(call.callState == CTCallStateConnected)
{
NSLog(@"Call is incoming");
}
else
{
NSLog(@"None of the conditions");
}
};
Now this works fine when, say a call is received by the user when the app is open. Upon, disconnecting the call, the app comes back automatically to the foreground and it detects rightly that the call state is disconnected.
However, if the app was backgrounded prior to receiving a call, then when the app comes back to the foreground, if i run the above piece of code, it fails to detect the call state. This is puzzling because the apple documentation states that:
If your application is active when a call event takes place, the system dispatches the event to your handler immediately. However, call events can also take place while your application is suspended. While it is suspended, your application does not receive call events. When your application resumes the active state, it receives a single call event for each call that changed state—no matter how many state changes the call experienced while your application was suspended. The single call event sent to your handler, upon your application returning to the active state, describes the call’s state at that time.
So i believe that, when my app resumes the active state and i run the call event handler block, it should detect that a call has just been disconnected. However, the call event handler block itself is not executed i.e it skips all the "if else" conditions and exits the block.
Can anyone throw light on why this is happening? Any help would be much appreciated. Thanks.