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.
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.
Share Improve this question edited May 23, 2017 at 12:18 CommunityBot 11 silver badge asked Oct 26, 2013 at 8:43 ZeriumZerium 17.4k32 gold badges118 silver badges187 bronze badges 5- can't you save them down in a list, and only show them sometimes? – user1251600 Commented Apr 29, 2014 at 7:44
- @BottleofMilk No, as it is site-wide - that is that notifications can basically be triggered by any page, so I can't keep track of them. – Zerium Commented Apr 29, 2014 at 7:44
- I see. What about websockets? – user1251600 Commented Apr 29, 2014 at 7:45
- @BottleofMilk Not particularly applicable for my situation. – Zerium Commented Apr 29, 2014 at 7:45
- You should send notifications with "collapse_key" set – eloibm Commented Jun 26, 2015 at 8:04
2 Answers
Reset to default 4Using the same solution, solved it by adding a tag property onto my notification instantiation
var notification = new Notification('Notification Title',
{
icon: 'http://cdn.sstatic/stackexchange/img/logos/so/so-icon.png',
body: "Hello Earth",
tag:"uniqueTag"
});
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);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744764272a4592362.html
评论列表(0条)