Overview
Channelize.io Calls JavaScript SDK allows integrating real-time high-quality one-to-one and one-to-many video and voice calls into an application. It is used to initialize, configure, and build video and voice calling functionality into your JavaScript application. This section includes initializing and basic use of Channelize.io Calls SDK.
Install and Initialize
Step 1: Install the SDK
Install the JavaScript Call SDK by just adding the below code snippet to the application:
<script src='https://cdn.channelize.io/calls/sdk/4.1.0/browser.js'></script>
Or you can also download the SDK from the URL in the above code snippet and add it to the HTML file.
Step 2: Initialize the SDK
Pass the Public Key of your Channelize.io application. Initialization is required only once when your application is loaded for the first time. Initializing the JavaScript SDK at the top of your application JavaScript file is recommended.
Get your Channnelize.io Application Public Key from the Channelize dashboard in Overview section.
var channelizeCall = new ChannelizeCall.client({publicKey: YOUR_PUBLIC_KEY});
Authentication
The authentication process for Channelize.io Calls is same as Channelize.io Chat SDK Authentication. Follow the below steps for user authentication using JavaScript SDK:
Log in to Channelize.io application server using our login API call or the login methods of our SDK. This login function will provide you an Access Token in response.
Save the User ID and the issued Access Token for the user to your Application's securely managed persistent storage.
When the user tries to log in to your application, you have to load the User ID and Access Token from the storage, and then pass them to the
channelize.connect()
method.You have to initialize the JavaScript SDK before connecting, by passing Public Key.
Please refer to Channelize.io SDK Authentication to know more about Login, Connect and Disconnect functions.
Code Snippet
Connect
var channelizeCall = new ChannelizeCall.client({publicKey: YOUR_PUBLIC_KEY});
var webrtcOptions = {}
channelizeCall.connect(userId, accessToken, webrtcOptions, function (err, res) {
});
Disconnect
channelizeCall.disconnect(deviceId, function (err, res) {
});