swiftsipvoiplinphonelinphone-sdk

Get CallerId (Username) from incoming call Linphone - Swift


I've just found a simple way to get the some CallLogs (CallerID, Username, To, From, Call duration, Date, Status, ...) from the new Linphone library for swift (SDK 5.0).

I just want to share it with you


Solution

  • Referring to Linphone's documentation, and some testings, I found at least 2 simple ways to retrieve the CallLog and read it:

    1. Using CoreDelegateStub

    CoreDelegateStub( onCallStateChanged: { (core: Core, call: Call, state: Call.State, message: String) in
    

    So, you can use the call attribute to get the CallerID(Username) for example, like that:

    call.callLog?.fromAddress?.username
    

    Remember, the callLog object contains a ton of parameters that you can find in the documentation

    2. Using Core from Linphone wrapper

    var mCore: Core!
    self.mCore.callLogs
    

    In that way, you can retrieve all your call logs in an array, so you will need to choose an item and get the attributes from it like I've shown above.

    self.mCore.callLogs[0].fromAddress?.username