Reputation: 17343
From this javascript question I learnt how to make desktop notifications work in Google Chrome, and decided to implement this on my site.
So every time a certain something happens, I am making a notification show.
The problem is, that most of the time, the user has more than one window open, which can display notifications, causing duplicate notifications.
Is there a way which allows me to not show duplicate Google Chrome notifications?
Thanks.
Upvotes: 5
Views: 4311
Reputation: 71
Using the same solution, solved it by adding a tag property onto my notification instantiation
var notification = new Notification('Notification Title',
{
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: "Hello Earth",
tag:"uniqueTag"
});
Upvotes: 4
Reputation: 118
I was facing a similar issue where in my Chrome Extension for Eye Rest would show a notification box every 20 minutes and if users don't close the notification box, 20 minutes later another would pop. The way I went about it was to use a callback function with setTimeout to automatically close the notification bar after a given time.
var notification = webkitNotifications.createNotification('48x48.png',"Notification Title","Notification Body");
notification.show();
setTimeout(function(){
notification.cancel();
},2000);
Upvotes: 1