【问题标题】:Push notification in Web pages在网页中推送通知
【发布时间】:2017-11-14 22:37:40
【问题描述】:

可以在网站中实现网络通知吗?我在前端使用带有 jquery、vue 和 angular.js 的 jsp 环境。有没有办法在这种环境下实现网络通知?

【问题讨论】:

    标签: angularjs jsp web push-notification vue.js


    【解决方案1】:

    您可以使用Notification API 来实现此目的。

    如果你想使用Service Workers从后端推送通知,你可以查看Push API

    这些 API 仍是草稿,可能仅适用于现代浏览器。确保您通过 https 使用这些 API。

    【讨论】:

      【解决方案2】:

      您可以使用已经集成在 Angular 中的 web socket。

      【讨论】:

        【解决方案3】:

        例如: https://github.com/mqttjs

        然后在你的 js 中:

            this.client = mqtt.connect(url, options);
        
            if(topics.length>0)
                this.client.subscribe(topics);
        
            this.client.on("message", (topic:any, payload:any)=>{
                console.log('CONNECTED', payload);
            });
        
            this.client.on("connect", function (connack: any) {
                console.log('CONNECTED', connack);
            });
        

        并使用一些服务器端消息代理,例如:rabbitMQ 或其他消息路由器

        读这个 https://www.rabbitmq.com/web-mqtt.html

        【讨论】:

          【解决方案4】:

          是的,Web 通知主要针对 Web 应用程序、客户端注册和用于推送通知的服务器端处理,以下站点有客户端和服务器端示例 -

          ServiceWorker

          【讨论】:

            猜你喜欢
            • 2018-09-18
            • 2019-05-13
            • 1970-01-01
            • 2014-05-10
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多