简体   繁体   English

发送推送通知到Chrome

[英]Sending push notification to Chrome

I am writing a simple Single Page Application that allows people to be chat. 我正在编写一个简单的单页应用程序,允许人们聊天。 The app will mainly be used on mobile devices (mainly Android, but some iOS although Android is the main focus). 该应用程序将主要在移动设备上使用(主要是Android,但主要关注Android的某些iOS)。

In terms of notifications, I was leaning towards https://github.com/primus/primus . 在通知方面,我倾向于https://github.com/primus/primus However, my main issue is that I need notifications to be delivered even when the users have their mobiles off -- or are not visiting the specific page. 但是,我的主要问题是,即使用户关闭了手机或没有访问特定页面,我也需要发送通知。

So, I am also looking into service workers and push notifications -- and am wondering if I should use those for everything and forget about Primus. 因此,我也正在调查服务人员和推送通知-并且想知道是否应该将这些用于所有内容,而忽略Primus。

So... questions: 所以...问题:

Questions: 问题:

  • Should I go for a hybrid architecture (Primus + Push notifications using web workers), or shall I stick with one? 我应该选择一种混合体系结构(使用Web工作者的Primus + Push通知),还是坚持?

  • Going the Service Worker's way, how would I go about it without using Firebase etc.? 按照服务工作者的方式,如何在不使用Firebase等的情况下进行处理? That is, what would the service worker look like? 也就是说,服务人员会是什么样子? And what would the push code (node/server and client side) look like? 推送代码(节点/服务器和客户端)是什么样的?

  • Again in terms of service workers, if the user restarts their phones, or for whatever reason the service worker isn't running on their client, is there a way for the server to know this? 同样,就服务人员而言,如果用户重新启动电话,或者由于某种原因服务人员未在其客户端上运行,服务器是否有办法知道这一点? (in that case, I'd send an SMS or an email...) (在这种情况下,我会发送短信或电子邮件...)

  • OR, is it even possible for a mobile site to get the device ID viewing the page, and go for a mobile push architecture instead? 或者,移动站点是否有可能获得查看页面的设备ID,而是采用移动推送架构?

Should I go for a hybrid architecture (Primus + Push notifications using web workers), or shall I stick with one? 我应该选择一种混合体系结构(使用Web工作者的Primus + Push通知),还是坚持?

You should not build an RTC system on the top of the Web Push API. 您不应在Web Push API的顶部构建RTC系统。 That's not the intended purpose of Web Push but offering a mechanism of notifying the user about timely events . 那不是Web Push的预期目的,而是提供了一种通知用户及时事件的机制。

You could use Web Push when you can not establish an RTC connection for getting the user to reopen your SPA and reconnect. 当您无法建立RTC连接以使用户重新打开SPA并重新连接时,可以使用Web Push。

Going the Service Worker's way, how would I go about it without using Firebase etc.? 按照服务工作者的方式,如何在不使用Firebase等的情况下进行处理? That is, what would the service worker look like? 也就是说,服务人员会是什么样子? And what would the push code (node/server and client side) look like? 推送代码(节点/服务器和客户端)是什么样的?

If you want to receive Web Push notifications in Android, you can not avoid Firevase since you need GCM (which now is Firebase Cloud Messaging). 如果要在Android中接收Web Push通知,则由于需要GCM(现在为Firebase Cloud Messaging),因此无法避免使用Firevase。

Again in terms of service workers, if the user restarts their phones, or for whatever reason the service worker isn't running on their client, is there a way for the server to know this? 同样,就服务人员而言,如果用户重新启动电话,或者由于某种原因服务人员未在其客户端上运行,服务器是否有办法知道这一点? (in that case, I'd send an SMS or an email...) (在这种情况下,我会发送短信或电子邮件...)

Honestly, I don't know. 老实说,我不知道。 But you could build your own ack system. 但是您可以构建自己的ack系统。 If you don't receive an ack in a reasonable time window you could assume the device is not receiving the notification. 如果您在合理的时间段内未收到确认,则可以认为设备未收到通知。

OR, is it even possible for a mobile site to get the device ID viewing the page, and go for a mobile push architecture instead? 或者,移动站点是否有可能获得查看页面的设备ID,而是采用移动推送架构?

Perhaps with specific browser extensions but not in a standard and cross-browser supported way. 也许使用特定的浏览器扩展,但不是以标准和跨浏览器支持的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM