chrome.alarms
Description: |
Use the chrome.alarms API to schedule code to run
periodically or at a specified time in the future.
|
Availability: |
Since Chrome 35.
|
Permissions: |
"alarms"
|
Learn More: |
Event Pages
|
Summary
Types | |
---|---|
Alarm | |
Methods | |
create −
chrome.alarms.create(string name, object alarmInfo)
| |
get −
chrome.alarms.get(string name, function callback)
| |
getAll −
chrome.alarms.getAll(function callback)
| |
clear −
chrome.alarms.clear(string name, function callback)
| |
clearAll −
chrome.alarms.clearAll(function callback)
| |
Events | |
onAlarm |
Types
Alarm
properties | ||
---|---|---|
string | name |
Name of this alarm. |
double | scheduledTime |
Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. |
double | (optional) periodInMinutes |
If not null, the alarm is a repeating alarm and will fire again in periodInMinutes minutes. |
Methods
create
chrome.alarms.create(string name, object alarmInfo)
Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm
event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes
or periodInMinutes
to less than 1
will not be honored and will cause a warning. when
can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
Parameters | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
string | (optional) name |
Optional name to identify this alarm. Defaults to the empty string. |
|||||||||
object | alarmInfo |
Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
|
get
chrome.alarms.get(string name, function callback)
getAll
chrome.alarms.getAll(function callback)
clear
chrome.alarms.clear(string name, function callback)
Clears the alarm with the given name.
Parameters | |||||
---|---|---|---|---|---|
string | (optional) name |
The name of the alarm to clear. Defaults to the empty string. |
|||
function | (optional) callback |
If you specify the callback parameter, it should be a function that looks like this: function(boolean wasCleared) {...};
|
clearAll
chrome.alarms.clearAll(function callback)
Clears all alarms.
Parameters | |||||
---|---|---|---|---|---|
function | (optional) callback |
If you specify the callback parameter, it should be a function that looks like this: function(boolean wasCleared) {...};
|