2017-05-09 170 views
0

我正在使用Linphone SDK構建安全的VoIP iOS應用程序。Linphone返回零ZRTP SAS(身份驗證令牌)

我成立了媒體加密權當應用程序啓動:

linphone_core_set_media_encryption(theLinphone.lc, LinphoneMediaEncryptionZRTP)

,我試圖檢索SAS這樣的:

linphone_call_get_authentication_token(Call.current())

大多數時候,它返回零。但偶爾它會返回一個十六進制值,如0x35422f6e6f697461

我甚至得到這個日誌: ortp-message-ZRTP secrets on: SAS is xxxx previously verified no是「xxxx」正確的SAS。

回答

0

所以我想清楚發生了什麼。

在呼叫狀態更改爲LinphoneCallOutgoingProgress後,我立即致電linphone_call_get_authentication_token(Call.current())。我需要做的只是開始一個Timer,當呼叫狀態改變爲LinphoneCallOutgoingProgress時,它每1秒調用一次方法,因爲需要一些時間才能生成SAS。以下是對我有用的東西:

timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { 

    DispatchQueue.main.async { 

     let sas = linphone_call_get_authentication_token(Call.current()) 

     if sas != nil { 

      self!.sasLabel.text = String(cString: sas!) 
      timer.invalidate() 
     } 
    } 
}