I am working on angular project and want to intergrate Ringcentral.
I read this Readme file and implmented that.
Following is my code:
var sdk = new RingCentral.SDK({
clientId: environment.rc_clientId,
clientSecret: environment.rc_clientSecret,
appName: environment.rc_appName,
// appVersion: appVersion,
server: RingCentral.SDK.server.sandbox, // or .production
});
var remoteVideoElement = document.getElementById('remoteVideo');
var localVideoElement = document.getElementById('localVideo');
console.log('media elements', remoteVideoElement, localVideoElement)
const platform = sdk.platform()
console.log("platform", platform)
platform.login({
jwt: environment.rc_jwt
}).then((rep) => rep.json()).then(loginResponse => {
return platform
.post('/restapi/v1.0/client-info/sip-provision', {
sipInfo: [{ transport: 'WSS' }],
}).then(resp => resp.json()).then(sipProvision => {
console.log(loginResponse, sipProvision)
return new RingCentral.WebPhone(sipProvision, {
// optional
clientId: environment.rc_clientId,
appName: environment.rc_appName,
uuid: loginResponse.endpoint_id,
logLevel: 1, // error 0, warn 1, log: 2, debug: 3
audioHelper: {
enabled: true,
incoming: 'path-to-audio/incoming.ogg',
outgoing: 'path-to-audio/outgoing.ogg',
},
media: {
remote: remoteVideoElement,
local: localVideoElement,
},
//to enable QoS Analytics Feature
enableQos: true,
});
}).then((webPhone) => {
console.log(webPhone);
this.session = webPhone.userAgent.invite('+19703725396');
console.log(this.session)
this.session.stateChange.addListener(state => {
console.log("session state", state)
})
webPhone.userAgent.on('invite', (session) => {
session.accept().then(result=>{
console.log('userAgent invitation accepted.', result)
})
})
}).catch((webPhoneError: any) => {
console.log(webPhoneError)
})
}).catch((errors: any) => {
console.error(errors)
})
This code didnt make call and the session of inviation of webPhone is terminated after Establising state.
What is this reason and how to fix. Please give me any tips.
Thank you.