gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 19:41:00 26 4
gpt4 key购买 nike

我在 iOS 10 中用 CXCallObserver 更改了 CTCallCenter。

这是我的代码:

#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");
}
}

但是我无法收到语音调用事件,并且收到如下警告:

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

请帮帮我。

最佳答案

不要忘记存储对callObserver 的强引用,这样它就不会过早释放:

@interface YourClass ()<CXCallObserverDelegate>
@property (nonatomic, strong) CXCallObserver *callObserver;
@end

- (void)viewDidLoad {
[super viewDidLoad];

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

更多信息,查看this回答。

关于objective-c - iOS 10 : How can I get a call event using CallKit/CXCallObserver?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39950419/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com