Webkit Notifications on Multiple Tabs

前端 未结 2 598
后悔当初
后悔当初 2020-12-16 00:30

I am using WebKit Notifications for my app. Say if I am using this code:

var n = window.webkitNotifications.createNotification(
   \'icon.pn         


        
2条回答
  •  清歌不尽
    2020-12-16 01:05

    You just need to specify "tag" option for notification. Notifications with the same value in tag only shows once even if many tabs are opened.

    For example:

    var notification = new Notification('Hey!', {
        body : 'So nice to hear from you',
        tag : 'greeting-notify',
        icon : 'https://mysite.com/my_funny_icon.png'
    });
    

提交回复
热议问题