2017-08-10 178 views
0

我正在嘗試檢測在Linphone呼叫期間正在呼叫我的號碼。我試過從Linphone呼叫獲取來電號碼

case LinphoneCallConnected: 
      NSLog("callStateChanged: LinphoneCallConnected") 
      NSLog("CALL ID: \(linphone_call_log_get_call_id(linphone_call_get_call_log(linphone_core_get_current_call(lc)))!)") 

但是這是空的。有另一種方法嗎?

回答

0

在我的應用程序中我採取linphoneCorelinphoneCall並在致電linphone_call_get_remote_address後。現在您有linphoneAddress,您可以從中提取用戶名linphone_address_get_username

全部代碼在這裏:

- (NSString *)userNameFromCurrentCall { 

    LinphoneCore *lc = [LinphoneManager getLc]; 
    LinphoneCall *currentcall = linphone_core_get_current_call(lc); 

    if (currentcall != NULL) { 
     LinphoneAddress const * addr = linphone_call_get_remote_address(currentcall); 

     if (addr != NULL) { 
      return [NSString stringWithUTF8String:linphone_address_get_username(addr)]; 
     } 
    } 

    return nil; 
}