W.venus W.venus - 6 months ago 368
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.


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.