I am using CTCallCenter
in my project. Now it's deprecated, I would like to know what are alternatives? How to get the event for the voice call?
Asked
Active
Viewed 6,780 times
9

Maxim Pavlov
- 2,962
- 1
- 23
- 33

MD Aslam Ansari
- 1,565
- 11
- 19
1 Answers
15
This is poorly documented, but I've found this mention in CTCallCenter
public header files:
"Replaced by
<CallKit/CXCallObserver.h>
"
So, from iOS 10 you should use CXCallObserver
class of new CallKit
framework to retrieve info about active calls:
CXCallObserver *callObserver = [[CXCallObserver alloc] init];
Provide object, conforming to CXCallObserverDelegate
protocol and queue, on which you want to perform delegate callbacks:
// If queue is nil, then callbacks will be performed on main queue
[callObserver setDelegate:self queue:nil];
// Don't forget to store reference to callObserver, to prevent it from being released
self.callObserver = callObserver;
and implement the following method on your delegate object:
- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call {
if (call.hasConnected) {
// perform necessary actions
}
}
For more information, you can check:
- Enhancing VoIP Apps with CallKit session from WWDC 2016
- Speakerbox sample project

Maxim Pavlov
- 2,962
- 1
- 23
- 33
-
1for the swift 3+ users solution is here https://stackoverflow.com/a/45469336/7230057 – Krishna Kumar Thakur Aug 02 '17 at 19:36
-
This solution works fine for Forground app state but not Background, any solution for Background state? – MrDEV Mar 12 '18 at 16:04