iViewer 5 and later on iOS supports SIP audio and video calls. Interaction with iViewer's SIP systems typically occurs by sending commands over to the system, and by listening to feedback it sends. In some cases getting events can be convenient, like when coming back from background.
This event is fired when a SIP call changes state. You currently can get notified when a call rings, is connected and is disconnected. The primary purpose of the event is to notify the Javascript code after a user pressed the Answer
button in a call notification alert that was displayed while the application was in background.
Example:
CF.userMain = function() {
// Start watching SIP call events
CF.watch(CF.SIPCallEvent, CF.SIPCallRingingIncoming, onSIPCallEvent);
CF.watch(CF.SIPCallEvent, CF.SIPCallRingingOutgoing, onSIPCallEvent);
CF.watch(CF.SIPCallEvent, CF.SIPCallConnected, onSIPCallEvent);
CF.watch(CF.SIPCallEvent, CF.SIPCallDisconnected, onSIPCallEvent);
};
function onSIPCallEvent(event, system, callID, oppositeNumber) {
CF.log("SIP call event="+event+" system="+system+", callID="+callID+", number="+oppositeNumber);
}
The CF.setSystemProperties function allows you to set properties for remote systems. Systems of SIP type expose a number of specific properties you can use to control the behavior of your connection to a SIP gateway. Please refer to the CF.setSystemProperties for base syntax and examples.
dialogFormat
(string): the format for textual commands sent to and received from SIP systems. One of CF.SIPDialogFormatRAW
(raw commands) or CF.SIPDialogFormatJSON
(json data). See the SIP system documentation on the CommandFusion wiki for a list of supported commands and notifications. The general rule of thumb is to use JSON when initiating and processing SIP messages with Javascript, and use the raw format when sending preformatted command using system commands and macros, and processing messages via system feedback processing.user
(string): the user name to identify with by the SIP gatewaypassword
(string): the password for user identification by the SIP gatewayidentity
(string): the identity string is determined by default and can be overridden by settingsuserAgent
(string): a custom user agent string. Defaults to the application's identifier and version (i.e. com.commandfusion.iViewer/5.0
)DTMFMode
(number): the mode for sending dial tones. One of CF.SIPDTMFModeAudio
(send out tones as sounds), CF.SIPDTMFModeRTP
(send DTMF over the RTP connection), CF.SIPDTMFModeInfoPackets
(send DTMF notifications as SIP info packets).transport
(string): the SIP transport method to use. One of CF.SIPTransportTCP
, CF.SIPTransportUDP
, CF.SIPTransportTLS
(secure TLS over TCP) or CF.SIPTransportDTLS_UDP
(secure TLS over UDP).outboundProxy
(string): if defined, the IP address of the SIP proxy to use for outbound calls. This is an advanced setting, use it only if you have very specific requirements.STUNServer
(string): if defined, the IP address of the SIP STUN server to use for UDP NAT. This is an advanced setting, use it only if you have very specific requirements.enableNAPTR
(boolean): whether SIP should enable Name Authority Pointer (NAPTR) supportRTPEncryption
(boolean): whether SIP should encrypt RTP connectionsAudioPort
(number): the local port to use for Audio streams. Use 0
to let SIP select a random port.AudioQuality
(number): the quality level for audio streams. One of CF.SIPAudioQualityLow
, CF.SIPAudioQualityStandard
or CF.SIPAudioQualityHigh
.audioCodecs.SILK
(boolean): enable the SILK codecaudioCodecs.OPUS
(boolean): enable the OPUS codecaudioCodecs.SPEEX
(boolean): enable the SPEEX codecaudioCodecs.ILBC
(boolean): enable the ILBC codecaudioCodecs.PCMA
(boolean): enable the PCMA codecaudioCodecs.PCMU
(boolean): enable the PCMU codecvideoCodecs.VP8
(boolean): enable the VP8 video codecvideoCodecs.MP4V
(boolean): enable the MP4 video codecvideoCodecs.H264
(boolean): enable the H.264 video codecvideoCodecs.H263
(boolean): enable the H.263 video codecbackgroundIncomingCall
(string): a string containing a JSON object with parameters specific to processing background incoming calls.The backgroundIncomingCall
object describes how the software should handle incoming SIP calls while the application is not frontmost. Options are to show an alert, automatically decline the call or do nothing (let the call follow up to voicemail if configured at the SIP gateway).
All fields are optional with default values and are as follows:
mode
(string): the mode is one of CF.SIPBackgroundCallModeIgnore
, CF.SIPBackgroundCallModeAlert
or CF.SIPBackgroundCallModeDecline
.title
(string): when mode
is CF.SIPBackgroundCallModeAlert
, the title string to use for the alert that's displayed to the user.message
(string): when mode
is CF.SIPBackgroundCallModeAlert
, the message template to use for the alert contents. If the message contains the string $CALLER$
, it will be replaced with the ID of the calling party.answerButton
(string): when mode
is CF.SIPBackgroundCallModeAlert
, the title of the button the user can tap to open the application.flipToPage
(string): if provided, the name of page to flip to when the application becomes frontmost after the Answer button was pressed.raiseJoin
(string): if provided, the name or tag of the digital join to raise after the answer button was pressed and the application was made frontmost. This is honored after any flipToPage
if one was provided. This allows, for example, displaying a specific subpage with a SIP call user interface.When the application is in background and has been configured to display an alert on incoming call, the answer button will ask the system to open the application and put it frontmost. Then your Javascript will receive a CF.SIPCallEvent
with a CF.SIPCallRingingIncoming
subevent. From then on, you can take the decision to answer the call by sending the appropriate command to the SIP system.
Use the flipToPage
and raiseJoin
properties to automatically switch to a specific page / display a subpage upon user pressing the Answer button on an incoming SIP call alert.