1分ごとに通知を表示するデスクトップ通知を作成しました。10 秒後、自動的に閉じます。
私は昼食をとりに行きました。その後、コンピュータはスリープ状態になります。私が戻ったとき、私は自分のコンピュータを目覚めさせ、たくさんの通知が始まります.
どうすればその問題を処理できますか? コンピューターがスリープ状態になっている場合は、通知を表示しないでください。どうすれば制御できますか?
Background.js
function show() {
var notification = webkitNotifications.createHTMLNotification(
'notification.html'
);
notification.show();
}
// Conditionally initialize the options.
if (!localStorage.isInitialized) {
localStorage.isActivated = true; // The display activation.
localStorage.frequency = 1; // The display frequency, in minutes.
localStorage.isInitialized = true; // The option initialization.
}
if (window.webkitNotifications) {
// While activated, show notifications at the display frequency.
if (JSON.parse(localStorage.isActivated)) { show(); }
var interval = 0; // The display interval, in minutes.
setInterval(function() {
interval++;
chrome.idle.queryState(15, state);
if(localStorage.frequency <= interval && state=="active")
{ show();
interval = 0;
}
}, 60000);
}