WebAPI/AlarmAPI: Difference between revisions

Jump to navigation Jump to search
m
Line 88: Line 88:
== FAQ ==
== FAQ ==


* Why the callback function set by <code>navigator.mozSetMessageHandler("alarm", function (message) { ... })</code> doesn't run when an alarm goes off?
* Why the callback function set by <code>navigator.mozSetMessageHandler("alarm", function (message) { ... })</code> doesn't work when an alarm goes off?
** You have to add a <code>messages</code> property in the application's manifest. The <code>messages</code> property is used to register the application as a potential target for catching certain types of messages, while <code>mozSetMessageHandler(...)</code> actually sets up the callback function that handles them. If you just call <code>mozSetMessageHandler(...)</code> without registering these messages previously, you won't receive them when an alarm goes off. Therefore, you have to add a <code>messages</code> property for registering the <code>"alarm"</code> message like below:
** You have to add a <code>messages</code> property in the application's manifest. The <code>messages</code> property is used to register the application as a potential target for catching certain types of messages, while <code>mozSetMessageHandler(...)</code> actually sets up the callback function that handles them. If you just call <code>mozSetMessageHandler(...)</code> without registering these messages previously, you won't receive them when an alarm goes off. Therefore, you have to add a <code>messages</code> property for registering the <code>"alarm"</code> message like below:


Confirmed users
110

edits

Navigation menu