iOS:无法在CallKit中获得传出呼叫事件 [英] iOS: Could not get outgoing call events in CallKit
问题描述
我正在使用"telprompt"通过我的应用进行呼叫,但是当呼叫结束时,我希望显示一个新的视图控制器并点击一个API来获取数据,所以我想接收一个事件以打开一个弹出窗口然后点击API.
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.
我尝试使用CallKit,但是未调用Delegate方法.
I have tried using CallKit, but Delegate method is not getting called.
这是我的代码.
#import <CallKit/CXCallObserver.h>
#import <CallKit/CXCall.h>
我符合CXCallObserverDelegate
I have conform to CXCallObserverDelegate
在viewDidLoad中:
In 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");
}
}
上面的方法没有被调用,您可以看到我已经设置了委托,我不知道我在做什么错.
Above method is not getting called, As you can see I have already set delegate, I don't know what I am doing wrong.
推荐答案
在为控制器创建了强大的引用/属性后,我丢失了对callObserver对象的强大引用.
I was missing a strong reference to the callObserver object after creating a strong reference/property to my controller it works well.
添加属性,并将callObserver对象放入其中.
Add the property and put callObserver object in it.
@property (nonatomic, strong) CXCallObserver *callObserver;
viewDidLoad:
viewDidLoad:
CXCallObserver *callObserver = [[CXCallObserver alloc] init];
[callObserver setDelegate:self queue:nil];
_callObserver = callObserver;
现在将调用Delegate方法.
Now Delegate method will be called.
干杯!!!
这篇关于iOS:无法在CallKit中获得传出呼叫事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!