Cấu hình SDK
Mã nhúng SDK
Hãy copy và dán đoạn mã sau vào ứng dụng của bạn.
/* Load Pitel SDK */
(function (a,b) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.onload = ()=>{PitelSDK.k=a;b()};
s.src = 'https://portal.tel4vn.com/pitelsdk/sdk-latest.min.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
})('d1ca84ac-2d98-4faa-92d4-699a6ce14eb7',()=>{
console.log('Pitel SDK Loaded');
setTimeout(function(){initSDK();}, 500);
});
/* Initialize Pitel SDK */
function initSDK() {
let sdkOptions = {
enableWidget: true,
sipOnly: true,
sipDomain: '',
wsServer: "",
sipPassword: "",
}
/*
Register delegates
Please check the SDK documentation for more information
https://documents.tel4vn.com/pitel_app/web/pitelsdk_web
*/
const sipDelegates = {
onCallCreated: function(remoteNumber, extra) {
console.log('onCallCreated', remoteNumber, extra)
},
onCallAnswered: function(remoteNumber, extra) {
console.log('onCallAnswered', remoteNumber, extra)
},
onCallReceived: function(remoteNumber, extra) {
console.log('onCallReceived', remoteNumber, extra)
}
}
let pitelSDK = new PitelSDK('NO_NEED', 'NO_NEED', '', sipDelegates, sdkOptions)
/* Example how to make call */
// pitelSDK.call(101, {
// extraHeaders: ['x-PROCESS-ID: 123'],
// earlyMedia: true
// })
}