admin管理员组文章数量:1391995
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);
本文标签: javascriptHow to not show duplicate Google Chrome notificationsStack Overflow
版权声明:本文标题:javascript - How to not show duplicate Google Chrome notifications? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744764271a2623942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论