Gustavo Amgarten
Gustavo Amgarten

Reputation: 396

Show just one web notification at once on the desktop

I've been working with HTML5 web notifications on desktop, and they seem to work really well. But I'm just showing them as in the default behavior of the browser. This means that when I send multiple notifications they stack up to 3, and then as older ones get closed, the waiting ones appear in place.

What I want to know if its possible, and if it is how I can do it, is if I can show just one, not three notifications at once, and if there's a new one to show, put it in the place of the previous one.

I hope I was clear on my problem, let me know otherwise.

Thanks in advance.

Upvotes: 2

Views: 1075

Answers (1)

Gustavo Amgarten
Gustavo Amgarten

Reputation: 396

Well, I found out by myself, and the key was the tag attribute.

When you create a new notification with the same tag as an existing one, the new one replaces the old one.

So if the goal is to display only one notification at once, just create the notifications always using the same tag.

For instance:

var notification = new Notification(
        "Title", {
        tag: 1
    }
);

Upvotes: 3

Related Questions