我将CallKit与VoIP应用集成在一起。我能够打电话和传出电话。我遵循了步骤:
- configureaudiosession
- startaudio在(DIDACTIVATE)
- (didDeActivate) stopaudio
我已经实施了DTMF提供商委托的回调,如下所示:
func provider(_ provider: CXProvider, perform action: CXPlayDTMFCallAction) {
print("Provider - CXPlayDTMFCallAction")
let dtmfDigts:String = action.digits
for (index, _) in dtmfDigts.characters.enumerated() {
let dtmfDigit = dtmfDigts.utf8CString[index]
print("Processing dtmfDigit:(dtmfDigit)" )
self.softphone.dtmf(on:dtmfDigit)
}
self.softphone.dtmfOff()
// Signal to the system that the action has been successfully performed.
action.fulfill()
}
我听不到键盘声音,即,当我在通话过程中按一个数字时,本地DTMF声音。
来自https://developer.apple.com/reference/callkit/cxplaydtmfcallaction:
" Callkit自动播放相应的DTMF频率 通过通话传输的任何数字。该应用程序负责 管理数字的时间和处理,作为实现的一部分 动作。"
这是一个已知问题或Callkit不播放本地DTMF键按声音?
callkit应在本机内通用UI的'键盘'按钮中按键时在本地播放DTMF音调。但是CallKit应用程序负责将DTMF音调通过其自己的网络接口发送到远程侧。
如果您不听到本机内室内UI本地播放的音调,请向Apple报告一个错误。
我能够通过:
使它起作用func provider(_ provider: CXProvider, perform action: CXPlayDTMFCallAction) {
print("Provider - CXPlayDTMFCallAction")
self.softphone.audioController.configureAudioSession()
let dtmfDigts:String = action.digits
for (index, _) in dtmfDigts.characters.enumerated() {
let dtmfDigit = dtmfDigts.utf8CString[index]
print("Processing dtmfDigit:(dtmfDigit)" )
self.softphone.dtmf(on:dtmfDigit)
}
self.softphone.dtmfOff()
// Signal to the system that the action has been successfully performed.
action.fulfill()
}
注意:我添加了self.softphone.audiocontroller.configureaudiosession()。
-(void) configureAudioSession
{
// Configure the audio session
AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
// we are going to play and record so we pick that category
NSError *error = nil;
[sessionInstance setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
if (error) {
NSLog(@"error setting audio category %@",error);
}
// set the mode to voice chat
[sessionInstance setMode:AVAudioSessionModeVoiceChat error:&error];
if (error) {
NSLog(@"error setting audio mode %@",error);
}
NSLog(@"setupAudioSession");
return;
}