2016-12-13 85 views
2

我正在將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

回答

1

我能夠使其通過工作:

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

當按下本機通話用戶界面的「按鍵區」按鍵中的按鍵時,CallKit應在本地播放DTMF鈴聲。但是CallKit應用程序負責通過其自己的網絡接口將DTMF音調發送到遠程端。

如果您沒有聽到在本地通話用戶界面本地播放的鈴聲,請向蘋果公司索取report a bug