Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

iOS detect incoming call?

I am using CXCallObserver in Swift 3 to detect an incoming call.

Problem is, it only works when the app is in the foreground. How do I make it work when the app is in the background?

This is for legit reasons, so if anyone knows of a way even if it uses other background states, such as location or fetch, please let me know and I will find a way to include that into the application.

Code
var callObserver = CXCallObserver()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      
      callObserver.setDelegate(self, queue: nil)
}

Code
func callObserver(_ callObserver: CXCallObserver, callChanged call: CXCall) {
      
      if call.hasConnected {
         print("Call Connect -> \(call.uuid)")
      }
      
      if call.isOutgoing {
         print("Call outGoing \(call.uuid)")
      }
      
      if call.hasEnded {
         print("Call hasEnded \(call.uuid)")
      }
      
      if call.isOnHold {
         print("Call onHold \(call.uuid)")
      }
   }
External call notifications are reported to CXProvider, so make sure to use that (or maybe you just didn't include that part in your post?).
In general, events propagate through different scopes, so if you handle it at the wrong scope it might cause the kind of problems you are having.

Need code? PM me.
BTC: 3PFFec6db8JP7zj3qDBRLd6YQGac7xy3LN
ETH: 0x1a89E6E8665ECD817F15CA8d5dAbA4Eaed2A9aEe
I was not using CXProvider. I will take a look, thank you.
I see that CXProvider is only for VOIP, whereas I am using normal Telephony.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by itcorpAug 26, 2025 12:35 PM 3 451 Aug 26, 2025 12:35 PM
Last Post: Weeds
[Python] by jackie420Aug 20, 2023 02:45 AM 2 129 Aug 20, 2023 02:45 AM
Last Post: Lucky4L
[C] by Praet0rianFeb 5, 2017 11:33 AM 22 958 Feb 5, 2017 11:33 AM
Last Post: Russ.