Chrome桌面通知给所有用户 [英] Chrome Desktop notification to all users

查看:163
本文介绍了Chrome桌面通知给所有用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Chrome桌面通知添加到我的网站。
我跟着这个:

Chrome桌面通知示例



我已将脚本代码添加到我的网站,并且它对我很好,
但我有问题。



当我点击通知按钮时,通知就会出现在我身上,但
我希望向所有授予该权限的用户显示通知。 / p>

任何人都可以帮助我吗?

解决方案

错误的文档 - 或者说,只有它的一部分。显示通知(您解决了这个问题)并将其交付给其他人(您没有这样做,并且令人惊讶地不知道它已经丢失)的问题是独立的。

你必须为节目编码本地通知,但没有什么可以实际发送(推送)消息或接收它。总之,还有很多工作要做。



您需要的是 Push API 。它涉及为您的站点创建一个服务工作者(这将成为能够听取推送消息的部分)并且具有与Google Cloud Messaging进行对话以生成推送的服务器端代码。有关如何使用它的精彩教程


I have tried to add Chrome Desktop notification to my website. I have followed this:

Chrome desktop notification example

and I have added the script code to my website and it work fine with me, but I have a problem.

When I click on "notify" button the notification just appears to me, but I want the notification be shown to all users who granted the permission.

Can anyone help me please?

解决方案

You're looking at wrong documentation - or rather, only one part of it. There are separate problems of displaying the notification (which you solved) and delivering it to others (which you didn't, and alarmingly didn't understand that it's missing).

You have to code the show a local notification, but there's nothing to actually send out (push) the message or receive it. In short, there's still a lot of work to be done.

What you need is the Push API. It involves creating a Service Worker for your site (which will be the part able to listen to push messages) and having server-side code that talks to Google Cloud Messaging to generate a push. There's a good tutorial on how to use it.

这篇关于Chrome桌面通知给所有用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆