我正在尝试将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);
}];
}
在来电者班:
CallProviderDelegate *providerDelegate = [[CallProviderDelegate alloc] init];
[providerDelegate reportNewIncomingCallWithUUID:[NSUUID UUID] handle:@"Raj" completion:^(NSError * _Nullable error) {
//
}];
答案 0 :(得分:2)
在你的"来电者" class,即实例化CallProviderDelegate
类并将其分配给providerDelegate
变量的代码,是否将providerDelegate
对象引用存储在实例变量或属性中?如果仅将其分配给临时局部变量,则在调用方法完成执行后将释放CallProviderDelegate
对象,如果释放CallProviderDelegate
对象,则不会再传递任何CXProvider委托消息
我检查您的CallProviderDelegate
对象是否未被意外取消分配。