Version: Smart Feature Phone 3.0



Alarm API allows applications to schedule notification at a specific time in the future. For example, some applications like alarm-clock, calendar or auto-update might need to utilize the Alarm API to trigger particular device behaviors at specified time points.

Alarms persist after reboot. When bootup, all expired alarms are fired immediately. When an alarm is fired, it is dispatched to applications through the System Message API, so applications which want to react to alarms have to register themselves to the alarm messages.

Alarm API exposes to both Window and Worker scope.

Get all alarms#

(list) => console.log(list), // Array of alarm objects.
(err) => console.log("getAll err: " + err)

Add an alarm#

options =
"date": new Date( + 10*60*1000),
"data": {"note": "take a nap"},
"ignoreTimezone": false
(id) => console.log("add id: " + id),
(err) => console.log("add err: " + err)

Remove an alarm#


Handle alarm#

Applications need to subscribe system message of type "alarm" to receive alarm messages.

Subscribe alarm#

Use from main scripts#

navigator.serviceWorker.register("sw.js").then(registration => {
rv => {
console.log('Successfully subscribe system messages of name "alarm".');
error => {
console.log("Fail to subscribe system message, error: " + error);

Receive alarm#

self.onsystemmessage = (e) => {
console.log("receive systemmessage event on sw.js!");
console.log(; // The alarm object