WebAPI/AlarmAPI: Difference between revisions

Jump to navigation Jump to search
→‎FAQ: Descirve how to set the messages property for app before using mozSetMessageHandler.
(Add moz prefix for the usages of system messages APIs.)
(→‎FAQ: Descirve how to set the messages property for app before using mozSetMessageHandler.)
Line 84: Line 84:


== FAQ ==
== FAQ ==
* Why the callback function set by <code>navigator.mozSetMessageHandler("alarm", function (message) { ... })</code> doesn't run 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 receives them. If you just call <code>mozSetMessageHandler(...)</code> without registering these messages before, you won't get them when an alarm goes off. For example, you have to add a <code>messages</code> property for registering the <code>"alarm"</code> message like below:
  "messages": ["alarm"]


* Why?
* Why?
Confirmed users
110

edits

Navigation menu