Integrate Linkus SDK for Web Core
'Linkus SDK for Web Core' provides core call functionalities without UI components. This topic describes how to integrate 'Linkus SDK for Web Core' with your Web project.
Prerequisites
Demo and Source code
Before the integration, we recommend that you try out the React Demo of 'Linkus SDK for Web Core', and review the source code to have an overview of the framework and workflow of 'Linkus SDK for Web Core'.
Supported module formats
Step 1. Import 'Linkus SDK for Web Core'
- Go to the GitHub Repository of 'Linkus SDK for Web Core', and download 'Linkus SDK for Web Core'.
- Use either of the following methods to import 'Linkus SDK for Web Core' to
your Web project.
- Use npm to install 'Linkus SDK for Web
Core'
npm install ys-webrtc-sdk-core
- Use script to import 'Linkus SDK for Web
Core'
<script src="./ys-webrtc.umd.js"></script>
- Use npm to install 'Linkus SDK for Web
Core'
Step 2. Initialize 'Linkus SDK for Web Core'
Name | Type | Description |
---|---|---|
PBXOperator | Object | This object contains methods and attributes related to the PBX, such as querying CDR records, logging out of user account, and more. |
PhoneOperator | Object | This object contains methods and attributes related to calls, such as making a call, answering a call, ending a call, and more. |
destroy | Method | This method is used to destroy 'Linkus SDK for Web Core'. |
- Method
-
init({ params //Refer to the following table for specific parameters })
- Parameters
-
Parameter Type Required Description username string Yes Extension number or email address. secret string Yes Linkus SDK login signature. pbxURL URL | string Yes The URL for accessing your PBX system, including the transfer protocol. For example, https://192.168.1.1:8088 .
enableLog boolean No Whether to enable log output and report error logs to PBX. Valid value:true
: Enablefalse
: Disable
Note: This feature is enabled by default.reRegistryPhoneTimes number No Define the number of retry attempts for SIP UA (User Agent) registration. By default, it is unlimited. userAgent WebPC" | "WebClient No The User Agent in Asterisk, which indicates the type of Linkus client. The default value is WebClient. deviceIds { cameraId?: string; microphoneId?: string;} No Define the IDs of the audio and video input devices, including the camera ID and microphone ID. disableCallWaiting boolean No Whether to disable call waiting. Valid value:true
: Disable call waiting.The call waiting time set on PBX will NOT take effect and the PBX only handles a single call.
false
: Enable call waiting.
- Sample code
-
- Use npm to install and initialize 'Linkus SDK for Web
Core'.
import { init, on } from 'ys-webrtc-sdk-core'; init({ username: '1000', secret: 'sdkshajgllliiaggskjhf', pbxURL: 'https://192.168.1.1:8088' }) .then((operator) => { // Obtain the 'PhoneOperator' instance, 'PBXOperator' instance, and 'destroy' method const { phone, pbx, destroy } = operator; }) .catch((error) => { console.log(error); });
- Use script to import and initialize 'Linkus SDK for Web
Core'.
<script src="./ys-webrtc.umd.js"></script> <script> // After successful import, initialize 'Linkus SDK for Web Core' using the 'YSWebRTC' object YSWebRTC.init({ username: '1000', secret: 'sdkshajgllliiaggskjhf', pbxURL: 'https://192.168.1.1:8088', }) .then((operator) => { // Obtain the 'PhoneOperator' instance, 'PBXOperator' instance, and 'destroy' method const { phone, pbx, destroy } = operator; }) .catch((error) => { console.log(error); }); </script>
- Use npm to install and initialize 'Linkus SDK for Web
Core'.