Re: Agenda SDK Dialog: How can a JS SDK app integrate with the phone app
Here is a small example how to use the phone-API:
function onPhoneApiUpdate (arg0) {
const provider = arg0.providers[0]
const calls = arg0.model[provider].model.calls;
calls.forEach(function(call) {
console.log("DEBUG " + JSON.stringify(call));
});
}
phoneApi = start.consumeApi("com.innovaphone.phone");
if (phoneApi) {
phoneApi.onupdate.attach(onPhoneApiUpdate);
}
You attach a callback function to the onupdate event of the phone-API.
Your callback function "onPhoneApiUpdate" gets called every time a new call comes or goes and everytime the call state changes.
All the call's details like call-state or remote party information you find in the argument of "onPhoneApiUpdate".
Here is an example of an incoming call:
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Alerting"}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Connected"}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Holding"}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Connected"}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Released"}
If the call is release by remote party, Softphone-App will hold the call 2 more seconds and plays a disconnect tone. After these 2 seconds the Softphone-App goes automatically onhoonk and the call is deleted from UI.
/Thomas