I'm writing a Chrome extension, and I keep getting an error message that chrome.alarms is undefined.
My manifest.json file:
{
"manifest_version": 2,
"name": "C",
"description": "whatever",
"version": "1.0",
"background": {
"scripts": ["background.js"],
"persistent": false
},
"permissions": ["background", "storage", "notifications", "alarms"],
"browser_action": {
"default_icon": "logo.png",
"default_title": "C",
"default_popup": "popup.html"
}
}
In my background.js file:
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
chrome.alarms.create('arbitrary', {
when: 1000,
periodInMinutes: 0.05
});
});
chrome.alarms.onAlarm.addListener(function (alarm) {
console.log('alarm called');
});
In my popup.js file:
$(document).ready(function() {
chrome.runtime.sendMessage({addressInfo: 'text'});
});
I have it loaded on my computer as an unpacked extension, so periodInMinutes
and when
1 minute constraints specified by the Chrome API documentation don't apply here.