I'm writing a Chrome extension that reminds the user of something every X minutes, using event pages, alarms, and the Chrome extensions notifications API.
The problem is that if the user lets the notification window disappear (it's on screen for only ~10 seconds), it will never be displayed again. This seems like a bug in Chrome, but wanted to check if maybe I'm missing something.
chrome.alarms.create('remindUser', {
delayInMinutes: 1,
periodInMinutes: 5
});
chrome.alarms.onAlarm.addListener(function (alarm) {
chrome.notifications.create(alarm.name, {
type: 'basic',
title: 'Reminder',
message: '...',
buttons: [
{ title: 'Act on it' },
{ title: 'Later' }
]
}, function callback(notificationId) {
// nothing necessary here, but required before Chrome 42
console.log(notificationId, 'notifications ARE called repeatedly, but the window is not displayed');
});
});
Nothing special in manifest.json
:
"permissions": ["alarms", "notifications", "storage", "contextMenus"]
If I click on the x
button to close the notification, it will be displayed next time. But if I'm away from the computer and don't do anything when the notification shows up, it will never be displayed again. The console shows the remindUser notifications ARE called repeatedly [...]
message with an increasing count, but the notification is not displayed again.
How can this be fixed? I'd rather not use the Notification
API because it bugs the user for permission.