CTCallCenter is deprecated. What is the alternative?

自闭症网瘾萝莉.ら 提交于 2019-11-28 03:23:43

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/39569937/ctcallcenter-is-deprecated-what-is-the-alternative

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!