CXPlayDTMFCallAction不播放本地dtmf声音

问题描述:

我正在将CallKit与VOIP应用程序集成。我能够接听和拨打电话。我跟着步骤:CXPlayDTMFCallAction不播放本地dtmf声音

  1. ConfigureAudioSession
  2. startAudio在(didActivate)
  3. stopAudio在(didDeActivate)

我已经实现为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() 
} 

我听不到按键声音,例如,当我在nat上按数字时发生本地dtmf声音呼叫期间的呼入用户界面。

https://developer.apple.com/reference/callkit/cxplaydtmfcallaction

“CallKit自动播放用于 通过呼叫传送的任何数字的相应的DTMF频率该应用程序负责 管理的数字的定时和处理作为履行 动作的一部分。 “。

这是一个已知问题还是callkit不能播放本地dtmf按键按下声音?

+0

“原生拨号程序”是指电话应用程序中的“小键盘”选项卡,还是指本机调用UI中显示的“小键盘”按钮? –

+0

@StuartM是,原生通话用户界面。 – ssk

我能够使其通过工作:

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; 
} 

当按下本机通话用户界面的“按键区”按键中的按键时,CallKit应在本地播放DTMF铃声。但是CallKit应用程序负责通过其自己的网络接口将DTMF音调发送到远程端。

如果您没有听到在本地通话用户界面本地播放的铃声,请向苹果公司索取report a bug