Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS How to check if currently on phone call

Tags:

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?

like image 450
friend Avatar asked Jun 08 '12 02:06

friend


People also ask

Does iPhone show time call started or ended?

Answer: A: Open the Phone app, tap Recents at the bottom of the screen, tap All at the top of the screen, tap the blue "i" in a circle at the right of the call; the date, time, and length of the call are displayed.

How do you check call duration on iPhone?

Answer: A: After you have just called someone, tap of that last call, you will see the duration of the call.

How do I put someone on hold on my iPhone?

Adjust the audio during a call Or swipe down on the call banner, then do any of the following: Mute: Tap the mute button. Put the call on hold: Touch and hold the mute button.


2 Answers

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.

like image 129
ThomasW Avatar answered Oct 06 '22 00:10

ThomasW


#import <CoreTelephony/CTCallCenter.h> #import <CoreTelephony/CTCall.h>  -(bool)isOnPhoneCall {     /*       Returns TRUE/YES if the user is currently on a phone call       */      CTCallCenter *callCenter = [[[CTCallCenter alloc] init] autorelease];     for (CTCall *call in callCenter.currentCalls)  {         if (call.callState == CTCallStateConnected) {             return YES;         }     }     return NO; } 
like image 40
AlBeebe Avatar answered Oct 06 '22 01:10

AlBeebe