Created
June 27, 2016 02:46
-
-
Save chenghaoc/74f99ee50eb714e60a6dd60dfa399d44 to your computer and use it in GitHub Desktop.
Ringcentral-web-phone with CommonJS module bundler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var RingCentral = require('ringcentral') | |
var WebPhone = require('ringcentral-web-phone') | |
var appKey = '...'; | |
var appSecret = '...'; | |
var appName = '...'; | |
var appVersion = '...'; | |
var sdk = new RingCentral({ | |
appKey: appKey, | |
appSecret: appSecret, | |
appName: appName, | |
appVersion: appVersion, | |
server: RingCentral.server.production // or .sandbox | |
}); | |
var platform = sdk.platform(); | |
platform | |
.login({ | |
username: '...', | |
password: '...' | |
}) | |
.then(function(loginResponse) { | |
return platform | |
.post('/client-info/sip-provision', { | |
sipInfo: [{transport: 'WSS'}] | |
}) | |
.then(function(res) { | |
return new 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 | |
} | |
}); | |
}); | |
}) | |
.then(function(webPhone){ | |
// YOUR CODE HERE | |
}) | |
.catch(function(e){ | |
console.error(e.stack); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment