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: 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.
Answer: A: After you have just called someone, tap of that last call, you will see the duration of the call.
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.
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.
#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; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With