CTCallCenter is not giving disconnected state

487 views Asked by At

I am using call functionality in my application. I want to call one API when call is disconnected. I am using following code in application didFinishLaunchingWithOptions.

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 == CTCallStateDialing)
    {
        NSLog(@"Call is dialing======================");
    }
    else
    {
        NSLog(@"None of the conditions===============");
    }
};

This code is giving me correct state for very first time. i.e When I make call, it gives me call dialing and when call ends, it gives me disconnected state. But when I install same app again in device without deleting it, then it gives me dialing state. But when call ends, it do not give me disconnected state. Please help. Thank you.

1

There are 1 answers

0
user1586900 On

'CTCallStateDisconnected' will be called only if you decline the GSM call. if you answer GSM call then 'CTCallStateConnected' will be called, here you have to set some flag saying GSM is connected once the GSM call ends then in your app applicationDidBecomeActive() using the flag you have to do whatever you want eg. resume calls.