Handling call events

Listening to the call events#

In order to listen to the call events you need to set delegate to the CallManagerDelegate sdk using the below method

CallManager.delegate = self
func sendCallMessage( groupCallDetails : GroupCallDetails ,users : [String], invitedUsers : [String])
func onMuteStatusUpdated(muteEvent: MuteEvent, userId: String)
func onCallStatusUpdated(callStatus: CALLSTATUS, userId: String)
func onCallAction(callAction: CallAction, userId: String)
func onLocalVideoTrackAdded(userId: String)
func onUserSpeaking(userId: String, audioLevel: Int)
func onUserStoppedSpeaking(userId: String)
func onLocalVideoTrackAdded(userId : String, videoTrack: RTCVideoTrack)
func onRemoteVideoTrackAdded(userId : String, track: RTCVideoTrack)
func socketConnectionEstablished()
func getGroupName(_ groupId : String)
info

AudioLevel ranges from 0 to 10, 0 being very low sound and 10 being too loud.

Handling mute events#

Whenever call end user mute/unmute video or audio, the below delegate will be triggered.

func onMuteStatusUpdated(muteEvent: MuteEvent, userJid: String) {
switch muteEvent {
case .ACTION_REMOTE_AUDIO_MUTE:
break
case .ACTION_REMOTE_AUDIO_UN_MUTE:
break
case .ACTION_REMOTE_VIDEO_MUTE:
break
case .ACTION_REMOTE_VIDEO_UN_MUTE:
break
case .ACTION_LOCAL_AUDIO_MUTE:
break
case ACTION_LOCAL_AUDIO_UN_MUTE:
break
}

muteEvent value will be anyone of the values of annotation class MuteEvent.

muteEvent ValueCall event
MuteEvent.ACTION_REMOTE_VIDEO_MUTEwhen the remote user muted his video
MuteEvent.ACTION_REMOTE_VIDEO_UN_MUTEwhen the remote user unmuted his video
MuteEvent.ACTION_REMOTE_AUDIO_MUTEwhen the remote user muted his audio
MuteEvent.ACTION_REMOTE_AUDIO_UN_MUTEwhen the remote user unmuted his video
MuteEvent.ACTION_LOCAL_AUDIO_MUTEwhen the local user muted his audio
MuteEvent.ACTION_LOCAL_AUDIO_UN_MUTEwhen the local user unmuted his video

Handling call status events#

Whenever call status changed in video or audio call, the below delegate will be triggered.

func onCallStatusUpdated(callStatus: CALLSTATUS, userId: String) {
}

callStatus value will be anyone of the values of annotation class CallStatus.

callStatus ValueCall event
CallStatus.CALLINGthe initial state of the call
CallStatus.CONNECTINGThe current call is in connecting state
CallStatus.RINGINGthe remote user is having internet and acknowledged the call
CallStatus.ATTENDEDthe user attended call and UI can be presented with the users in the call
CallStatus.CONNECTEDthe call is successfully connected and audio/video tracks transmission is about to start
CallStatus.DISCONNECTEDthe call is disconnected and call UI can be closed
CallStatus.RECONNECTINGthe call is in reconnecting state
CallStatus.RECONNECTEDthe call is connected back after a reconnecting state
CallStatus.ON_HOLDthe remote user has put your call on hold, it will happedn when the remote user attended gsm call
CallStatus.ON_RESUMEthe remote user has resumed your call after a on hold, it will happen when the remote user disconnected gsm call
CallStatus.CALL_TIME_OUTwhen we don't receive ack for the outgoing call from the remote user within 30 seconds, When we don't receive ack for the incoming call from the caller within 30 seconds, When we don't receive ack for the call invite from the invited user within 30 seconds

Handling call action events#

Whenever call action received in video or audio call, the below delegate will be triggered,

func onCallAction(callAction: CallAction, userId: String) {
}

callAction value will be anyone of the values of annotation class CallAction.

callAction ValueCall event
CallAction.ACTION_LOCAL_HANGUPwhenever you disconnect the call, the action will be received
CallAction.ACTION_DENY_CALLwhen you decline the incoming call, the action will be received for callee
CallAction.ACTION_PERMISSION_DENIEDwhen you attend the incoming call without required permissions, the action will be received for the callee
CallAction.ACTION_REMOTE_ENGAGEDwhen the remote user is engaged in the another call, the action will be received for the caller
CallAction.ACTION_REMOTE_BUSYwhen the remote user declines incoming the call, the action will be received for the caller
CallAction.ACTION_AUDIO_DEVICE_CHANGEDwhenever the audio device changed in call, update the audio device UI
CallAction.ACTION_INVITE_USERSWhen you invite users to the call, this will be triggered so that you can update your UI
CallAction.ACTION_VIDEO_CALL_CONVERSION_REJECTEDWhen remote user declined our video call switch request
CallAction.ACTION_VIDEO_CALL_CONVERSION_ACCEPTEDWhen remote user accepted our video call switch request
CallAction.ACTION_VIDEO_CALL_CANCEL_CONVERSIONWhen remote user cancels the video call switch request made by them
CallAction.ACTION_CAMERA_SWITCH_DONEWhen camera switch done, the action will be received
CallAction.CHANGE_TO_AUDIO_CALLWhen ui needs to be changed as audio call ui this action will be received
CallAction.ACTION_REMOTE_VIDEO_ADDEDWhen the remote user video track is received, this action will be received
CallAction.ACTION_PERMISSION_DENIEDWhen Audio or Camera permission is denied and makes a call
CallAction.INCOMING_ACTION_PERMISSION_DENIEDWhen Audio or Camera permission is denied and receives a call

Handling the video track events#

When the remote user video track is received, this action will be received: CallAction.ACTION_REMOTE_VIDEO_ADDED. When this action is triggered, request SDK to fetch the track of the user

CallManager.getRemoteVideoTrack(jid: USER_JID)

Observing the Missed call Notification on Foreground#

In order to Observe the missed call notification in foreground you need to set the delegate MissedCallNotificationDelegate in AppDelegate using the below method

CallManager.missedCallNotificationDelegate = self
public protocol MissedCallNotificationDelegate {
/**
When the user receives any missed call in foreground this callback will be triggered.
*/
func onMissedCall(isOneToOneCall: Bool, userJid: String, groupId: String?, callType: String, userList: [String])
}