从Linphone电话获取来电号码

时间:2017-08-10 19:00:32

标签: iphone swift voip linphone incoming-call

我正在尝试检测在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)))!)")

但是这是空的。还有另一种方式吗?

2 个答案:

答案 0 :(得分:1)

在我的应用中,我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;
}

答案 1 :(得分:0)

SString *)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;
相关问题