Skip to main content

Hi Team, We are using Ringcentral javascript SDk to make and receive calls. We did the authorization with java SDK and saved required tokens and using the same tokens in javascript sdk using below code platform.auth().setData(tokens); But here I confused on how to get the WebPhone from the platform object. Could you please provide me the code to create a WebPhone after setting the tokens to platform.

To implement a Web phone using Javascript, use the RingCentral Web phone SDK.


This is the modified version of the example code on Github:

var appKey = '...';
var appSecret = '...';
var appName = '...';
var appVersion = '...';

var sdk = new RingCentral.SDK({
appKey: appKey,
appSecret: appSecret,
appName: appName,
appVersion: appVersion,
server: RingCentral.SDK.server.production // or .sandbox
});

var remoteVideoElement = document.getElementById('remoteVideo');
var localVideoElement = document.getElementById('localVideo');

var platform = sdk.platform();
platform.auth().setData(tokens)
if (platform.loggedIn()){
platform.post('/client-info/sip-provision', {
sipInfo: [{transport: 'WSS'}]
})
.then(function(res) { // Doing nested then because we need loginResponse in a simple way
return new RingCentral.WebPhone(res.json(), { // optional
appKey: appKey,
appName: appName,
appVersion: appVersion,
uuid: loginResponse.json().endpoint_id,
logLevel: 1, // error 0, warn 1, log: 2, debug: 3
audioHelper: {
enabled: true, // enables audio feedback when web phone is ringing or making a call
incoming: 'path-to-audio/incoming.ogg', // path to audio file for incoming call
outgoing: 'path-to-audio/outgoing.ogg' // path to aduotfile for outgoing call
},
media:{
remote: remoteVideoElement,
local: localVideoElement
},
//to enable QoS Analytics Feature
enableQos:true
});

})
.then(function(webPhone){

// YOUR CODE HERE

})
}



Thank you Phong Vu. your answer was very helpful for me. I had completed the integration and everything is working fine. But I didn't find any option to dismiss/reject the call in RingCentral Web phone SDK.

This is the way I am initiating the call.

var session = webphone.userAgent.invite(toNumber, {

fromNumber : fromNumber

});


And one more doubt is I am not able to record the calls. Do we need a paid account to enable Call Recondings or can we test with the sandbox account?


The last doubt is Do we need the RingCentral paid plan to apply for production? When I am trying to apply for production its showing the messege as below.
https://i.snipboard.io/TO3pqe.jpg

Please help me to solve these confusions.

Thanks,

Mike


Reply