0

I am trying desktop notification using Notification.
My code

var notification = new Notification(title, {
  icon: 'logourl',
  body: 'notification',
  tag: "nftnId",
  renotify: true
});

Case: My URL opened in two tabs, one of my URL tabs is active and the other one is inactive. In this case, desktop notification happens but I want to prevent this action

  • Probably a dupe of [Webkit Notifications on Multiple Tabs](https://stackoverflow.com/questions/12928242/webkit-notifications-on-multiple-tabs). But it seems you are already using a `tag`. Are you sure that the `tag` is the same in both tabs? – Ivar Jun 03 '20 at 13:39
  • but not working for my case (Webkit Notifications on Multiple Tabs). @Ivar – Nivetha Ganeshan Jun 03 '20 at 13:46
  • The current dupe target is terrible in my opinion. Sure, you can prevent the notification if a tab is inactive, but if all tabs are inactive you end up without any notifications, which defeats the whole purpose of using notifications. – Ivar Jun 03 '20 at 13:47
  • @Nigetha You need to be more specific. Did you verify that the tags for are the same for the multiple notifications you receive? What browser are you using? – Ivar Jun 03 '20 at 13:48
  • two of my code URL tabs are open..now one is active and other is inactive.. desktop notification happens by the inactive tab code of desktop notification while I am in the active tab. – Nivetha Ganeshan Jun 03 '20 at 13:49
  • yes same tag. i am using chrome – Nivetha Ganeshan Jun 03 '20 at 13:56
  • I am in one of my opened tabs - another one is inactive. if i moved from all of my code tabs.. it working fine `1.opened 2 tabs --> I am not in my code url tab --> 1 desktop notification --> fine for me 2.opened 2 tabs --> I am in one of my tabs --> 1 desktop notification ` – Nivetha Ganeshan Jun 03 '20 at 13:58

0 Answers0