MozAlarmsManager.add()
This API is available on Firefox or Firefox OS for installed or higher privileged applications.
The add
method is used to retrieve a list of pending alarms.
Syntax
var request = navigator.mozAlarms.add(date, respectTimezone[, data]);
Properties
- date
- A Date object representing the time the alarm must be fired.
- respectTimezone
- A string that indicates if the alarm must be fired respecting the timezone set with the date. Possible values are
ignoreTimezone
orhonorTimezone
. - data Optional
- An arbitrary JavaScript object with data to be stored with the alarm.
Return
A DOMRequest
object to handle the success or failure of the method call.
If the method call is successfull, the request's result
will be a number representing the id of the alarm.
Example
var alarm = { date: new Date(<code class="js string">"July 27, 2013 20:00:00"</code>), respectTimezone: 'ignoreTimezone', data: { message: "Do something dude!" } }; var request = navigator.mozAlarms.add(alarm.date, alarm.respectTimezone, alarm.data); request.onsuccess = function () { console.log('A new alarm has been set:' + this.result); alarm.id = this.result; // get the id of the new alarm. } request.onerror = function () { console.log('operation failed: ' + this.error); }
Note: You need to use the same URL for setting and receiving an alarm. For example, If you invoke navigator.mozAlarms.add()
on foo.html or index.html?foo=bar, but have { "alarm": "/index.html" }
in your manifest messages field, you'll never receive the alarm.
Specification
Specification | Status | Comment |
---|---|---|
Web Alarms API | Working Draft | Defines the AlarmManager interface. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | No support | No support | No support | No support | No support |
Feature | Android | Firefox OS | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | No support | 1.0[1] | No support | No support | No support | No support |
[1] This API is currently available on Firefox OS only for any installed applications. The current specification for this API is not considered stable enough to unprefix the API yet.
See also
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/mozalarmsmanager/add