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.
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)")
}
}
