2017-08-10 242 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; 
}