Confirmed users
110
edits
m (→Features) |
(→FAQ) |
||
Line 88: | Line 88: | ||
== FAQ == | == FAQ == | ||
* Why the callback function set by <code> | * Why the callback function set by <code>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 the <code>"alarm"</code> message previously, you won't receive it 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 the <code>"alarm"</code> message previously, you won't receive it when an alarm goes off. Therefore, you have to add a <code>messages</code> property for registering the <code>"alarm"</code> message like below: | ||
"messages": ["alarm"] | "messages": ["alarm"] | ||
* Does the <code>getAll(...)</code> return the alarms that were not added by its belonging application? For example, if the Alarm Clock app calls the <code>getAll(...)</code>, will the alarms added by the Calendar app also be returned? | |||
** No, the <code>getAll(...)</code> only returns the alarms scheduled by the application. | |||
* Similarly, how about the <code>remove(...)</code>? Can an application delete the alarms added by other applications? | |||
** No, the Alarm API can only interact with alarms scheduled by the same app. | |||
* Supposing an alarm is set at 8:00am, but the device shuts down from 7:00am to 9:00am. Will the Alarm API fire an <code>"alarm"</code> message for that when the device powers up next time? | |||
** Yes, it will fire as soon as the device powers up. | |||
* Does the <code>getAll(...)</code> return the alarms that have already been fired? Or the back-end will keep them before the <code>remove(...)</code> is explicitly called? | |||
** The back-end won't keep the fired alarms, which means only alarms that have not fired will be returned. | |||
* What happened if the app attempts to add an alarm which has a past setting time? | |||
** The <code>add(...)</code> will set the <code>DOMRequest.error</code> to an <code>InvalidStateError DOMError</code>. | |||
* Why? | * Why? |