我正在尝试将CallKit集成到我的Voip应用程序中。我引用了Apple WWDC的SpeakerBox示例代码。我创建了ProviderDelegate类,并且可以在调用reportNewIncomingCall
方法之后看到传入的UI。
但是,当我点击“答案” /“结束”按钮时,不会触发相应的提供程序代表。这有什么问题吗?
请注意,在实例化providerDidBegin
时会调用“CallProviderDelegate
”。
@implementation CallProviderDelegate
- (instancetype)init
{
self = [super init];
if (self) {
_providerConfiguration = [self getProviderConfiguration];
_provider = [[CXProvider alloc] initWithConfiguration:_providerConfiguration];
[_provider setDelegate:self queue:nil];
}
return self;
}
- (void)providerDidBegin:(CXProvider *)provider {
// this is getting called
}
- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {
// this is not getting called when the Answer button is pressed
}
- (void)reportNewIncomingCallWithUUID:(nonnull NSUUID *)UUID handle:(nonnull NSString *)handle
completion:(nullable void (^)(NSError *_Nullable error))completion {
CXCallUpdate *update = [[CXCallUpdate alloc] init];
update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:handle];
update.hasVideo = NO;
[_provider reportNewIncomingCallWithUUID:UUID update:update completion:^(NSError * _Nullable error) {
completion(error);
}];
}
在 call 者类别中:
CallProviderDelegate *providerDelegate = [[CallProviderDelegate alloc] init];
[providerDelegate reportNewIncomingCallWithUUID:[NSUUID UUID] handle:@"Raj" completion:^(NSError * _Nullable error) {
//
}];
最佳答案
在“调用者”类中,即实例化CallProviderDelegate
类并将其分配给providerDelegate
变量的代码,您是否将providerDelegate
对象引用存储在实例变量或属性中?如果仅将其分配给临时局部变量,则在调用方法完成执行后,将释放CallProviderDelegate
对象,如果释放了CallProviderDelegate
对象,则将不再传递任何CXProvider委托消息。
我会先检查您的CallProviderDelegate
对象是否未被意外释放。
关于ios - 没有触发CXProviderDelegate方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39845522/