2
我正在嘗試將CallKit集成到我的Voip應用程序中。我提到了Apple WWDC的SpeakerBox示例代碼。我創建了一個ProviderDelegate類,我可以在調用reportNewIncomingCall
方法後看到來電UI。CXProviderDelegate方法不會觸發
但是當我點擊「答案」/「結束」按鈕時,相應的提供者代表未被解僱。這裏有什麼可能是錯的?
請注意,當我實例化CallProviderDelegate
時,會調用「providerDidBegin
」。
@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) {
//
}];
是的,我犯了這個確切的錯誤,稍後修復它。忘記更新線程。感謝您花時間回答斯圖爾特。 – Rajavelu
@Rajavelu:你可以讓我知道你怎麼能把APP的CallKit UI前端? –
@SaurabhPrajapati您需要從提供者委託中調用'reportNewIncomingCall'方法。 – Rajavelu