NotifyClient - Client
-
- UpdatedJan 30, 2025
- 8 minutes to read
- Yokohama
- API reference
The NotifyClient API provides methods that enable you to use Notify telephony functionality, such as making and receiving calls from a web browser.
Several NotifyClient methods take a callback function as a parameter. Because NotifyClient method calls are made asynchronously, these methods can't return a value directly. Use the callback function to parse the returned data, such as by assigning variables or making other API calls.
NotifyClient - Client(Object notifyConfig, Boolean initializeVendorClientLazily)
Instantiates a new Notify WebRTC Client object.
Example
The following example shows how to create the NotifyClient constructor, register various event listeners, and initialize the client driver.
NotifyClient - addEventListener(String event, Function fn)
Registers an event handler to listen for changes in a Notify client.
Using this method you can register multiple listeners. Each listener must be a separate method call.
Name | Type | Description |
---|---|---|
event | String | Name of the event to listen for. Instead of passing strings, use the
constants defined in
|
Type | Description |
---|---|
Function | Function to use to de-register a listener. |
Example
This example shows how to register multiple listeners.
Example
This example shows how to de-register a listener.
NotifyClient - call(Object identifier)
Calls the specified phone number or the phone number associated with a specified user.
SNC.Notify.Status
.Name | Type | Description |
---|---|---|
identifier | Object | JSON object that contains either a phone number to call or the sys_id of a
WebRTC user. Passing a user sys_id causes the call to be made through
browser-to-browser communication. You can obtain the user sys_id from the Notify WebRTC Session table. Note: If you provide both a phone number and user sys_id,
the method only uses the phone number. |
Type | Description |
---|---|
void |
Example
This example demonstrates passing a phone number as the function parameter.
Example
This example demonstrates passing a user record sys_id as the function parameter.
Example
This example shows a button click handler.
Example
This example shows an event handler.
NotifyClient - destroy()
Kills the current Notify client, rendering it unusable.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
void |
NotifyClient - forwardCall(Object argument)
Forwards an ongoing incoming or outgoing phone call to either a different phone number or a different WebRTC client.
Name | Type | Description |
---|---|---|
argument | Object | JSON object that contains the necessary information for forwarding the call to either a phone number or a WebRTC client (user sys_id). You can obtain this sys_id from the Notify WebRTC Session table. |
Type | Description |
---|---|
void |
Example
This example demonstrates forwarding a call to a different phone number. The dtmf attribute allows you to send DTMF dial tones to the receiving number.
Example
This example demonstrates forwarding a call to a different Notify client.
NotifyClient - getAvailableClients(Function callback)
Returns a list of clients available to accept calls.
This method excludes the current client from the list. The equivalent Notify-getAvailableClients() method does not filter any user.
Name | Type | Description |
---|---|---|
callback | Function | Function to use to parse the list of clients. This function accepts a single parameter, an array of JSON objects with the following format: |
Type | Description |
---|---|
void |
NotifyClient - getParentId(String callId, Function callback)
Returns the parent call identifier for a specified call identifier, if one exists.
Depending on the telephony provider, there may be a delay before the parent call identifier is returned; therefore you must provide a callback function.
Name | Type | Description |
---|---|---|
callId | String | Unique identifier of the call for which to return the parent call identifier. |
callback | Function | Function that obtains the JSON object that contains either the parent call identifier or an error message if the identifier could not be obtained after several tries. |
Type | Description |
---|---|
String | Parent call identifier. |
Example
This example shows how to use this method to obtain the parent call identifier.
Example
This example shows the contents of the jsonObj parameter.
NotifyClient - getStatus()
Returns the normalized status of the current call.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Current status of the call. The values returned by the telephony provider API are normalized by replacing the returned driver value with its equivalent value as defined in SNC.Notify.Status. |
Example
This example shows how to obtain the status of the current Notify client.
NotifyClient - hangupCall()
End the current call.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
void |
Example
This example how to hang up a call.
NotifyClient - init()
Initializes the client driver.
For example, when using the Twilio client, it invokes the method Twilio.Device.setup(). Call this method after the user has interacted with the page. This initialization process is asynchronous, therefore, you must provide an ONLINE event handler. This handler is called when the setup process is complete and the system is ready to take or make calls.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
void |
Example
This example shows how to initialize the Notify client.
NotifyClient - mute(Boolean muted)
Mute or unmute the current client.
Name | Type | Description |
---|---|---|
muted | Boolean | Mutes or unmutes the current call.
|
Type | Description |
---|---|
void |
Example
This example shows how to send mute the current call.
NotifyClient - pickupCall()
Answers and connects to an incoming call from a WebRTC client.
Call this method when there is a notification of an incoming call.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
void |
Example
This example shows how to pickup a call.
NotifyClient - sendDtmf(String digits)
Send one or more DTMF-valid digits over the current call.
Name | Type | Description |
---|---|---|
digits | String | One or more DTMF-valid digits. |
Type | Description |
---|---|
void |
Example
This example shows how to send DTMF signals to the current call.
NotifyClient - setCallerId(String value, Function autoSelectVendorCallback)
Sets the caller ID for the current client session.
You can change or update the caller ID at any time however, the caller ID must belong to the same vendor.
Name | Type | Description |
---|---|---|
value | String | Phone number to use to make and receive calls. |
autoSelectVendorCallback | Function | Optional.
initializeVendorClientLazily must be set
to "true" in the constructor to use this function, otherwise an error is thrown.
Name of the callback function to call once the vendor is automatically set for the specified phone number. With this option, the vendor does not need to be specified in the constructor (notifyConfig.vendor). Auto vendor selection is an asynchronous operation. Therefore, this callback is required to indicate when it is safe to call notifyConfig.init(), as this method requires that the vendor be set before it is called. In addition, you must also check if notifyConfig.vendor has been set in the callback to ensure that a vendor has been specified. |
Type | Description |
---|---|
void |
Example
This example shows how to set the caller ID. This example assumes that the vendor is set in the constructor.
NotifyClient - setClientAvailable(Boolean available)
Sets the availability of an active WebRTC client agent.
This type of availability is different than an agent being in a call. In this case, an active WebRTC client may be connected and not on a call, but may not want to receive calls.
Calling this method updates the Available field value on the Notify Client Connected Session [notify_client_session] record associated with this client session. You can get a list of available clients using the getAvailableClients() method.
Name | Type | Description |
---|---|---|
available | boolean | Flag that indicates whether an active WebRTC client wants to receive calls.
|
Type | Description |
---|---|
void |
On this page
- NotifyClient - Client(Object notifyConfig, Boolean initializeVendorClientLazily)
- NotifyClient - addEventListener(String event, Function fn)
- NotifyClient - call(Object identifier)
- NotifyClient - destroy()
- NotifyClient - forwardCall(Object argument)
- NotifyClient - getAvailableClients(Function callback)
- NotifyClient - getParentId(String callId, Function callback)
- NotifyClient - getStatus()
- NotifyClient - hangupCall()
- NotifyClient - init()
- NotifyClient - mute(Boolean muted)
- NotifyClient - pickupCall()
- NotifyClient - sendDtmf(String digits)
- NotifyClient - setCallerId(String value, Function autoSelectVendorCallback)
- NotifyClient - setClientAvailable(Boolean available)