WebAPI/AlarmAPI: Difference between revisions

Jump to navigation Jump to search
m
(→‎FAQ: Descirve how to set the messages property for app before using mozSetMessageHandler.)
Line 75: Line 75:
   navigator.mozAlarms.remove(alarmId2);
   navigator.mozAlarms.remove(alarmId2);


* How to listen to the alarm-fired message with a callback function (executed when the alarm goes off)?
* How to listen to the <code>"alarm"</code> message with a callback function which will run whem an alarm goes off?


   navigator.mozSetMessageHandler("alarm", function (message) { alert("alarm fired: " + JSON.stringify(message)); });
   navigator.mozSetMessageHandler("alarm", function (message) { alert("alarm fired: " + JSON.stringify(message)); });


* How to know in advance if there exists any pending alarm-fired messages?
* How to know in advance if there exists any pending <code>"alarm"</code> messages?


   navigator.mozHasPendingMessage("alarm");
   navigator.mozHasPendingMessage("alarm");
Confirmed users
110

edits

Navigation menu