1)调用结束问题
com.apple.callkit.error.requesttransaction code=4表示 UUID 未知。
CXErrorCodeRequestTransactionErrorUnknownCallUUID = 4
要在 CallKit 框架中正确结束通话,您必须CXEndCallAction
使用您的独特UUID
和请求事务从CXCallController
.
CXEndCallAction *action = [[CXEndCallAction alloc] initWithCallUUID:c_UUID];
[self.callController requestTransaction:[CXTransaction transactionWithActions:@[action]] completion:completion];
在提供者方法中,您应该通过 pjsip 结束您的通话,并且不要忘记调用[action fulfill]
.
- (void)provider:(CXProvider *)provider performEndCallAction:(nonnull CXEndCallAction *)action {
// get your current pjsip call object
...
// make hangup - something like:
pj_status_t status = pjsua_call_hangup([self identifier], 0, NULL, NULL);
if (status != PJ_SUCCESS) {
NSString *errStr = [NSString stringWithFormat:@"Error hanging up call %@", self];
ALog(@"%@", errStr);
}
[action fulfill];
}
2) 接听电话后的音频问题
当您接受呼叫时,将触发以下方法- (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession
,当您结束呼叫时,将调用此方法(void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession
。
- (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession{
// start audio and configure pjsip sound
pj_status_t status = pjsua_set_snd_dev(input, output); // '0' for input and output
}
并在以下方法中停用 pjsip 调用的声音。
- (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession{
// end audio
pj_status_t status = pjsua_set_null_snd_dev();
}