iOS How to check if currently on phone call

friend picture friend · Jun 8, 2012 · Viewed 14.3k times · Source

I have look around and all I can find is checking the callState of CTCallCenter. However, this works by listening to an event - which depending on whether the application is active/suspended/resumed the event can be raised at different time.

What I need is rather than listening to event and got told when call is connected, I want to decide myself when to ask if the call is connected.

Use case: When phone call is connected - user knows and will always click on the app icon, which will open the app. At this time I just want to run a quick function to check if currently on call or not.

Is this even possible?

Answer

ThomasW picture ThomasW · Jun 8, 2012

The CTCallCenter object has a currentCalls property which is an NSSet of the current calls. If there is a call then the currentCalls property should be != nil.

If you want to know if any of the calls is actually connected, then you'll have to iterate through the current calls and check the callState to determine if it is CTCallStateConnected or not.