diff --git a/site/en/docs/extensions/reference/alarms/index.md b/site/en/docs/extensions/reference/alarms/index.md index 2b6ec33efe25d..cbd10e99d487d 100644 --- a/site/en/docs/extensions/reference/alarms/index.md +++ b/site/en/docs/extensions/reference/alarms/index.md @@ -17,6 +17,39 @@ To use the `chrome.alarms` API, declare the `"alarms"` permission in the [manife } ``` +## Concepts and usage + +### Device sleep + +The behavior of alarms when a device goes to sleep is currently undefined. An alarm will never fire +early but may fire significantly later than expected if a device went to sleep after an alarm was +scheduled. + +### Persistence + +Alarms generally persist until an extension is updated. However, this is not guaranteed, and alarms +may be cleared when the browser is restarted. Consequently, consider setting a value in storage +when an alarm is created, and then ensure it exists each time your service worker starts up. For example: + +```js +const STORAGE_KEY = "user-preference-alarm-enabled"; + +async function checkAlarmState() { + const { alarmEnabled } = await chrome.storage.get(STORAGE_KEY); + + if (alarmEnabled) { + const alarm = await chrome.alarms.get("my-alarm"); + + if (!alarm) { + await chrome.alarms.create({ periodInMinutes: 1 }); + } + } +} + +checkAlarmState(); +``` + + ## Examples The following examples show how to use and respond to an alarm. To try this API,