Rate this page:

Web SDK

You can install the Web SDK via NPM:

npm i voximplant-websdk --save
#or
yarn add voximplant-websdk

Or by mounting a JavaScript library to your webpage (the minified version of the web SDK is available on our CDN): <script type="text/javascript" src="//cdn.voximplant.com/edge/voximplant.min.js"></script>

WEB PAGE SHOULD BE LOADED OVER HTTPS

Most modern web browsers limit voice and video capture only to web pages loaded over HTTPS. This also means that such a page can't be loaded from a local .html file. For development purposes, local files can be self-hosted. Web browsers allow loading self-hosted pages from localhost over HTTP.

Getting started with VoxImplant.Client singleton

VoxImplant.Client is a Singleton class and the main class of the SDK that provides access to VoxImplant's functions, getInstance function is used to receive its instance as shown below:

getInstance

getInstance

After the Voximplant JavaScript library has been loaded it should be initialized using the init method before any other method of the SDK can is called. The optional VoxImplant.Config instance can be passed to the init method in order to configure the SDK. The VoxImplant.Events.SDKReady event will be triggered after the SDK has been successfully initialized. Please see the following example:

init

init

After the SDK is initialized, the connect function should be called to establish a data connection between a browser and the Voximplant Cloud in order to accept and initiate calls. Thus, a developer should add the following event listeners to handle connection events:

connect

connect

The last thing that should be done before the call object can be used is authorization: the Application User's username and password should be passed to the login method. The VoxImplant.Events.AuthResult event is triggered to notify about the login result. For better security, our SDK also provides two additional login methods: with one-time login keys and with renewable tokens.

login

login

Using VoxImplant.Config to specify SDK settings during the initialization

There is a number of settings that can be specified while the SDK initialization, let's review them all one-by-one:

  • micRequired - if set to true, SDK will show microphone access dialog right after the initialization of the SDK. The VoxImplant.Events.MicAccessResult event will be triggered after the user allowed or denied access to the microphone
  • videoSupport - can be used to enable video calls support,
  • progressToneCountry - Country code in ISO format for progress tone generated automatically if progressTone set to true. Has "US" value by default,
  • progressTone - Automatically plays progress tone by means of SDK according to specified progressToneCountry if set to true.
Progress tones

Please note that SDK currently supports only US and Russian progress tones generated automatically. We will add other countries soon. Meanwhile, you can use browser-based audio playback capabilities for that purpose.

The following example shows how the settings can be passed to the init function:

init settings

init settings