kandy-js

3.0.0-beta

createKandy

The Kandy.js SDK Factory. Create an instance of the SDK by calling this factory with the the desired configurations.

createKandy(configs: Object)
Parameters
configs (Object) The configuration object.
Example
// Instantiate the SDK.
let kandy = createKandy({
authentication: { ... },
logs: { ... },
...
});
// Use the Kandy API.
kandy.on( ... );

configs

The configuration object. This object defines what different configuration values you can use when instantiating the SDK.

configs
Configurations By Feature
configs.logs
configs.notifications
configs.authentication
configs.call
configs.connectivity

Events

Events
API Functions
on(type, listener)
off(type, listener)
subscribe(listener)
unsubscribe(listener)

Authentication

Kandy's authentication feature handles connecting and disconnecting from any backend services that the SDK deals with. As well, it handles and stores authentication information on the behalf of the user. This allows the user to interact with the server without worrying about authenticating.

Authentication
API Functions
connect(credentials)
disconnect()
updateConnection(connection)
getUserInfo()
getConnection()
getServices()
subscriptionStates
Events
auth:change
auth:error

Calls

Kandy's call feature is used to make audio and video calls between Kandy users, or to PSTN phones and SIP endpoints. Kandy will store meta-information about each call made during the current session in internal state, which can be accessed via the call getter functions.

Call functions are namespaced beneath 'call' on the returned Kandy object.

Calls
API Functions
getAll()
getById(callId)
states
mediaStates
make(callee, options?)
answer(callId, options?)
ignore(callId)
reject(callId)
end(callId)
mute(callId)
unmute(callId)
startVideo(callId, options?)
stopVideo(callId)
hold(callId)
unhold(callId)
startScreenshare(callId, options)
stopScreenshare(callId)
sendDTMF(callId, tone)
forwardCall(callId, destination)
directTransfer(callId, destination)
consultativeTransfer(callId, destination)
join(callId, destination)
Events
call:start
call:receive
call:join
call:forward
call:stateChange
call:mediaStateChange
call:screenshareChange
call:error

Media

Kandy's media features are used to control WebRTC Media Devices.

Media functions are namespaced beneath 'media' on the returned Kandy object.

Media
API Functions
setDefaultDevices(devices)
getDevices()
startPreviewVideo(videoContainer?)
stopPreviewVideo()
Events
videoPreview:change
videoPreview:error
devices:defaultsChange
media:initialize

CallHistory

Kandy's call history feature is used to retrieve and inspect the authenticated users call logs.

CallHistory functions are namespaced beneath 'call.history' on the returned Kandy object.

CallHistory
API Functions
fetch(amount, offset)
remove(recordId)
clear()
get()
Events
callHistory:change
callHistory:error

Messaging

Kandy's Messaging features revolve around a "conversation" structure. Kandy stores the conversations and its messages, and returns conversation objects when requested.

See the "Conversation" and "Message" sections of the documentation for more details.

Messaging functions are namespaced beneath 'conversation' on the returned Kandy object. Ex: kandy.conversation.get('id').

Messaging
API Functions
get(userId)
Events
conversations:change
messages:change
messages:error

Conversation

A Conversation object represents a conversation between either two users, or a user and a group. A Conversation can spawn messages via the conversations createMessage() function.

Conversation
API Functions
createMessage(part)
clearMessages()
getMessages()
subscribe(callback)
fetchMessages(amount)

Message

A Message object represents an inidividual message. Messages in Kandy have parts which represent pieces of a message, such as a text part or a file part. Once all the desired parts have been added, a message can be sent with the send() function.

Message
API Functions
send()

Presence

Kandy's presence functions are used to update the authenticated users presence on the server, as well as retrieve other users presence information.

Presence functions are namespaced beneath 'presence' on the returned Kandy object.

Presence
API Functions
update(status, activity, note)
get(users?)
fetch(users)
subscribe(users)
unsubscribe(users)
Events
presence:change
presence:error

Voicemail

Kandy's mwi (Message Waiting Indicator) features are used to retrieve and view voicemail indicators.

Voicemail functions are namespaced beneath 'voicemail' on the returned Kandy object.

Voicemail
API Functions
fetch()
get()
Events
voicemail:change
voicemail:error

SipEvents

Allows a user to subscribe to, and receive notifications for, sip events.

SipEvents functions are namespaced beneath 'sip' on the returned Kandy object.

SipEvents
API Functions
subscribe(eventType, subscribeUserList, clientCorrelator, customParameters?)
update(eventType, userLists, customParameters?)
unsubscribe(eventType)
getDetails(eventType?)
Events
sip:subscriptionChange
sip:error
sip:eventsChange

Connectivity

Kandy's connection feature is used to connect and maintain connections between the SDK and one or more backend servers.

Connectivity functions are namespaced beneath 'connectivity' on the returned Kandy object.

Connectivity
API Functions
getSocketState(platform)
enableConnectivityChecking(enable)
Events
ws:change

Notification

Notification
API Functions
registerPush(params)
deregisterPush()
enableWebsocket(enable)
Events
notifications:change
notifications:error

Users

Users functions are namespaced beneath 'users' on the returned Kandy object.

Users
API Functions
fetch(userId)
fetchDetails()
get(userId)
getSelf()

Contacts

Contacts functions are namespaced beneath 'contacts' on the returned Kandy object.

Contacts
API Functions
refresh()
add(contact)
remove(id)
update(id, contact)
search(criteria, type)

Logger

The internal logger used to provide information about the SDK's behaviour. Provide a log level as part of the SDK configuration (see configs.logs) to use the logger.

Logger
API Functions
levels

KandyError

The Kandy error object. Provides information about an error that occurred in the SDK.

KandyError
Properties
code (string) : The code of the error. If no code is known, this will be a string 'NO_CODE'.
message (string) : A human-readable message to describe the error. If no message is known, this will be a string 'An error occured'.