Reputation: 15844
I'm trying to set a periodical alarm to load data on background from time to time. When the extension is installed, the alarm is triggered after the delay correctly, no problem here. But then it goes away and no other repetition is done. I also tried to set persistent=true
which prevents it from going to the inactive mode but still no difference in behavior.
manifest.json
{
...
"background": {
"scripts": ["jquery-2.2.3.min.js", "common.js", "background.js"]
"persistent": false/true // tried both
},
"permissions": [
"<all_urls>",
"alarms",
"storage"
]
}
bgscript.js
chrome.runtime.onInstalled.addListener(function () {
chrome.alarms.create({delayInMinutes: 1});
});
chrome.alarms.onAlarm.addListener(function () {
doStuff();
});
Upvotes: 1
Views: 391
Reputation: 10897
As per the description of chrome.alarms.create, you should also set periodInMinutes
for repeating.
chrome.runtime.onInstalled.addListener(function () {
chrome.alarms.create({delayInMinutes: 1, periodInMinutes: 1});
});
Upvotes: 4