Detecting the Call Events in Ios

Detecting the call events in ios

Yes you can detect a Call. but only if your app is running in the foreground.
For this you can use the Core Telephony Framework.

If your app will fall in any of the background running categories (VOIP, AUDIO, Location tracking or accessory ) you might be able to use the
CTCallCenter in the background. But be aware that Apple will reject you app if you miss use the background running mode for something it was not meant for.

The CTCallCenter will allow you to detect any calls that are started or already in progress.

However you will not be able to detect any detail about the call, the CTCall identifying the call will only tell you this state. The callID of CTCall will just give you an unique identifier for the call but not the number being called.

Detect call events in iOS?

  1. Yes this class is available in iOS 10.
  2. No, you can only detect a phone call while in the foreground.
  3. No, this is not really possible, you might be able to start recording sound but only the user mic.

iOS How to detect call state in background?

Finally, I solved it! I used code from this answer: Find if user is in a call or not?

I removed everything from AppDelegate, all job is done in ViewController:

override func viewDidLoad()

selector: #selector(cameBackFromSleep),
name: NSNotification.Name.UIApplicationDidBecomeActive,
object: nil



private func isOnPhoneCall() -> Bool
let callCntr = CTCallCenter()

if let calls = callCntr.currentCalls
for call in calls
if call.callState == CTCallStateConnected || call.callState == CTCallStateDialing || call.callState == CTCallStateIncoming
print("In call")
return true

print("No calls")
return false

func cameBackFromSleep()


override func viewWillAppear(_ animated: Bool)
print("is on call", isOnPhoneCall())
switch isOnPhoneCall()
case true:
recordBtnIsPressed = true
case false:
recordBtnIsPressed = false
default: break

Now it works fine. Not sure why CTCallCenter works so weird in AppDelegate.

Detecting GSM Call States in IOS 10 (Swift 3, Xcode 8) and Notification from Background state

After a long while it looks like this may not be feasible in iOS 10. I did try using the background modes as suggested but neither i need to play music nor keep tracking the location at all times hence they do not work out for me.

I cannot use Push Kit because the intent is to get events for normal GSM calls and not voip calls.

How to detect programmatically that call is on hold in iOS?

We can use CallKit Framework to get the Call Hold event.

We need to conform to CXCallObserver Delegate

 [_callObserver setDelegate:self queue:nil];

where _callObserver is the instance of my CXCallObserver class

- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call {
if (call.isOnHold == true) {
NSLog(@"Call is on hold");

Get event for incoming call when application in background

Finally i managed it. there was an issue with my background GPS tracking functionality implementation, i have correct it and my code works like charm. So confirming that we can track call when application is in background.

Related Topics

Leave a reply