W.venus W.venus - 1 year ago 626
Objective-C Question

iOS 10 : How can I get a call event using CallKit/CXCallObserver?

I changed the CTCallCenter with CXCallObserver in iOS 10.

Here is my code:

#import <CallKit/CXCallObserver.h>
#import <CallKit/CXCall.h>

-(void)viewDidLoad {

CXCallObserver *callObserver = [[CXCallObserver alloc] init];
[callObserver setDelegate:self queue:nil];

... ...

- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call {
if (call.hasConnected) {
NSLog(@"********** voice call connected **********/n");
} else if(call.hasEnded) {
NSLog(@"********** voice call disconnected **********/n");

But I can't get a voice call event and I got a warning like this:

Sending 'HomeViewController *const __strong' to parameter of incompatible type 'id<CXCallObserverDelegate> _Nullable

Please help me.

Answer Source

You missed the CXCallObserverDelegate.

@interface HomeViewController : UIViewController <CXCallObserverDelegate>


Then the warning will disappear and you get a voice call event. I hope this help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download