Questionable behavior of phone / phoneinfo api
Dear innovaphone forum,
We have noticed a strange behavior of what signals are sent by the phone / phoneinfo api when having more than one phone provider. We are currently using both apis, because com.innovaphone.phone has no "disconnected" signal.
Code:
var phoneinfoApi;
var phoneApi;
var phoneApi;
if(!phoneinfoApi) phoneinfoApi = start.provideApi("com.innovaphone.phoneinfo");
if(!phoneApi) phoneApi = start.consumeApi("com.innovaphone.phone");
if(!phoneApi) phoneApi = start.consumeApi("com.innovaphone.phone");
phoneinfoApi.onmessage.attach(function (sender, obj) {
switch (obj.msg.mt) {
case "CallAdded":
break;
case "CallUpdated":
break;
case "CallRemoved":
that.add(new innovaphone.ui1.Div(null, "Call ended"));
break;
}
});
switch (obj.msg.mt) {
case "CallAdded":
break;
case "CallUpdated":
break;
case "CallRemoved":
that.add(new innovaphone.ui1.Div(null, "Call ended"));
break;
}
});
phoneApi.onupdate.attach(function onPhoneApiUpdate(arg0) {
const providers = arg0.providers;
if(providers) providers.forEach(function (provider) {
const calls = arg0.model[provider].model.calls;
if(calls) calls.forEach(function (call) {
if (call.state == "Alerting") {
that.add(new innovaphone.ui1.Div(null, "Call incoming from provider: " + arg0.model[provider].title));
}
});
});
const providers = arg0.providers;
if(providers) providers.forEach(function (provider) {
const calls = arg0.model[provider].model.calls;
if(calls) calls.forEach(function (call) {
if (call.state == "Alerting") {
that.add(new innovaphone.ui1.Div(null, "Call incoming from provider: " + arg0.model[provider].title));
}
});
});
});
These are the messages we get:
Call incoming from provider: Softphone0
Call incoming from provider: Softphone0
Call incoming from provider: Softphone1
Call ended
Call ended
Call incoming from provider: Softphone1
After a call gets removed, the other provider pushes an alert at the ending.
How can we avoid this problem?
How can we identify a specific call, because every call currently has the id "-1"?
Is there a possibility to only use one of those apis instead of combindig them?