I'm working on an app, once the app goes to background(when the user taps the home button in iPhone) and receives and answers the phone call I have to perform some action.
Below is the code I tried,
callCenter = CTCallCenter()
self.callCenter!.callEventHandler = {(call: CTCall) -> Void in
if (call.callState == CTCallStateConnected)
{
//do something
}
else if (call.callState == CTCallStateDisconnected)
{
//do something
}
}
}
-- The event gets called when the app is foreground and receives the phone call, but doesn't work when the app is in the background.
Any solution to make it work?
Note: I'm submitting the app to the app store(iOS 9 and above, swift 2.3), so turning VoIP feature ON will not work for me as it might lead to rejection.