Picture of Rico 1837
Registered 10 years 245 days
Rico 1837 Thursday, 1 July 2021, 09:22 AM
Agenda SDK Dialog: How to send BatchCounterUpdates from the JS SDK
How to send BatchCounterUpdates from the JS SDK to an app icon in myApps without the user having to open the app.

For example, an email app that displays the number of unread emails on the app icon so that the user can then actively open the app.
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Thursday, 1 July 2021, 04:58 PM
Re: Agenda SDK Dialog: How to send BatchCounterUpdates from the JS SDK

On the WebSocket connection, between the App Object and the App Service, a PbxSignal message with an presence_notify facility must be sent. It will be forwarded to the myApps client by the PBX, even if no App is running in the client.

Required Steps:
1) Enable App Service for presence Subscriptions

On a C++ App Service:
void ApplicationSession::AppWebsocketAppInfo(const char * app, class json_io & msg, word base)
{
msg.add_bool(base, "presence", true);
}

On JavaScript App Service:
It is not possible at the moment. I could be added in the config.json on later release.

The myApps cleint will get following indication, if presence is enabled for the App Service:
{
"mt":"UpdateAppsInfo",
"app":{
"name":"chat",
"title":"Chat",
"url":"../../APPS/chat/chat",
"inline":true,
"info":{
"apis":{
"com.innovaphone.chat":{

},
"com.innovaphone.notificationhandler":{

}
},
"wake":[
"chat"
],
"presence":true
}



2) Handle incoming presence_subscribe call on the App Service:
new PbxApi("PbxSignal").onconnected(function (conn) {
log("Badge: new connection with PbxSignal support");
connections.push(conn);

conn.send(JSON.stringify({"api": "PbxSignal", "mt": "Register", "flags": "NO_MEDIA_CALL"}));

conn.onmessage(function (msg) {
var obj = JSON.parse(msg);
log("Badge: rcv" + msg);

if (obj.mt == "RegisterResult") {
// handele RegisterResult
}

if (obj.mt == "Signaling") {
// handle incoming presence_subscribe call => callid required later for sending badge notifications
}

});
});

3) Send presence_notfy facility into subscription call:
function updateBadge(count,callid) {

var msg = { "api": "PbxSignal", "mt": "Signaling", "call": callid, "src": "badge", "sig": { "type": "facility", "fty": [{ "type": "presence_notify", "status": "open", "note": "#badge:" + count, "contact": "app:" }] } };

connections.filter(function (v) { return v.api === "PbxSignal"; })[0]
.send(JSON.stringify(msg));
}



In the attached diagram I have marked the path with pink color.

BadgeCount.png

2013
Moderator Registered 16 years 15 days
Guntram Diehl (innovaphone) Thursday, 8 July 2021, 01:00 PM in response to Rico 1837
1 of 1 users consider this post helpful
Re: Agenda SDK Dialog: How to send BatchCounterUpdates from the JS SDK
With 13r2 sr1 the fix 112067 - Support presence subscriptions in the Javascript Runtime will be included.
With this fix you are able to add a property "presence":true in config.json in the "apis"/<your start html> object to indicate that you want to receive presence subscription calls on the websocket connection identified by the start html.

The 13r2 SDK documentation is also updated.
← You can define your color theme preference here