iOS: Could not get outgoing call events in CallKit

拜拜、爱过 提交于 2019-12-11 04:18:58

问题


I'm making a call through my app using 'telprompt', but when call ends I want a new view controller to be shown and hit an API to get data, So I want to receive an event to open a pop up and hit API.

I have tried using CallKit, but Delegate method is not getting called.

here is my code.

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

I have conform to CXCallObserverDelegate

In viewDidLoad:

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

Delegate method:

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

    } else if(call.hasEnded) {

        NSLog(@"********** voice call disconnected **********/n");

    }
}

Above method is not getting called, As you can see I have already set delegate, I don't know what I am doing wrong.


回答1:


I was missing a strong reference to the callObserver object after creating a strong reference/property to my controller it works well.

Add the property and put callObserver object in it.

@property (nonatomic, strong) CXCallObserver *callObserver;

viewDidLoad:

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

Now Delegate method will be called.

Cheers !!!



来源:https://stackoverflow.com/questions/43915871/ios-could-not-get-outgoing-call-events-in-callkit

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