1

I'm trying to create an alarm using browser.alarms API for web extensions. To make the extension cross-browser, I am using webextension-polyfill and testing on Chrome.

My code to create an alarm within a background script is shown below:

browser.alarms.create('spline-items-notification', {
  periodInMinutes: 1
});

However, when I attempt to run this extension, I always get an error:

Uncaught TypeError: Cannot read property 'create' of undefined

I am loading webextension-polyfill before the background script in manifest.json, and other interfaces work, like browser.notifications.

I would like to know how to fix this if possible. Thank you.

2 Answers2

4

alarms
To use this API you need to have the "alarms" permission.

Does the manifest.json have the "alarms" permission?

erosman
  • 7,094
  • 7
  • 27
  • 46
0

I think this a bug with webextension-polyfill, but I opened a pull request that should fix it.

evilpie
  • 2,718
  • 20
  • 21