The Web Background service enables web applications to run partly in the background, even when the browser is not running. The part of the JavaScript code that is executed in the background can use APIs such as XMLHttpRequest to communicate over the network and Web Notifications to get the user's attention.
1. Web Background Service
A labs.ericsson.com enabler
https://labs.ericsson.com/apis/web-background-service/
2. Web Background service
A stand-alone Java application that runs on
Android as well as on platforms supporting
Java Standard Edition
Enables web applications, running in the
browser, to run part of the application logic in
the background
The JavaScript code running in the
background will continue to run when the
associated web application running in the
browser is closed
2
3. Web Background features
The background JavaScript code can use
APIs such as XMLHttpRequest to
communicate over the network and Web
Notifications to get the user's attention
Remote Procedure Call (RPC) bridge allows
for simple interaction between the main
application and the background code
Management Console lets the user manage
currently running background applications
3
4. Web Background example
Simple banana counting script running
in the Web Background service
The background script updates the web
page with the current banana count using
RPC
When the web application running in the
browser is closed, notifications are used to
alert the user
4
5. Web Background example
Web application running in the browser
<html>
<head>
<title>Simple Web Background application</title>
<script src="wb.js"></script> <!– bootstrap script -->
<script>
wb.onload = function () {
wb.enable("icon.png", document.title, "Here's the description",
"persistent.js");
};
function log(msg) {
document.body.innerHTML += msg + "<br>";
}
</script>
</head>
<body>
</body>
</html>
5
6. Web Background example
persistent.js (running in the WB service)
var count = 0;
var notification;
wb.client.importFunctions("log");
wb.client.onconnect = function () {
setInterval(function() {
var msg = "number of bananas: " + count++;
if (wb.client.connected)
wb.client.log(msg);
else {
if (notification)
notification.cancel();
notification = notifications.createNotification("icon.png",
”Banana count", msg);
notification.show();
}
}, 3000);
};
6