Notification when Open Chrome

Asked

Viewed 277 times

1

Facebook currently fires notifications when opening Chrome. How can I do the same thing, i.e., trigger a notification as soon as the user opens Chrome?

  • Take a look at this post: Tableless.

  • I needed this only when the user opens Chrome like Facebook does.

1 answer

0

Hello, there is an API for browsers to display notifications. These notifications are created via javascript. Below contains examples of using the API.

if (("Notification" in window)) {
//Verifica se o navegador tem suporte à notificações

if (Notification.permission === "granted") {
//Verifica se a permissão foi concedida pelo usuário

Notification.requestPermission(function (permission) {
//Requisita permissão para o usuário

var notification = new Notification("Hi there!");
//Envia notificação

To deepen this subject, I left below some links of the documentation:

  • 1

    This is for Chrome? the link redirects to firefox...

  • It’s good for Chrome, but it’s not good for what I need, because I need notifications to occur when Chrome starts. Like Facebook has done. :(

  • For this you will need to use service Workers and create push Notifications. Follow Chrome API link.

  • Follow link, [https://developers.google.com/web/fundamentals/engage-andretain/push-notifications/]

  • Franco, I suggest you edit the answer with the link you just posted.

  • @diegofm Alterado

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.