PWA 的推送通知或 Web 推送通知 [英] Push notifications or Web push notifications for PWA

查看:103
本文介绍了PWA 的推送通知或 Web 推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我想声明我一直在研究推送通知和网络通知之间的关系,但我有点困惑.

first, I want to state that I've been researching between push notifications and web notifications but I'm a bit confused.

我从这里读到 PWA 的推送通知不适用于 Safari 上的 iOS(iPhone):从 PWA 向 iOS 发送推送通知

I've read that push notifications for PWAs don't work for iOS (iPhones) on Safari from here: Sending Push Notifications to iOS from PWA

但是,如果 iPhone 用户使用 Chrome,这是否意味着它们可以工作?或者推送通知不适用于任何浏览器上的 iPhone 中的 PWA?

However does it mean that they work if the iPhone user is using Chrome? Or push notifications don't work for PWAs in iPhones on any browser?

这让我看到了网络通知.Web 通知是否适用于后台的 PWA?我的问题是 Web 通知是否足以替代推送通知,还是 Web 通知不能由服务器触发,因此仍然需要推送通知?

This brings me to web notifications. Do web notifications work for PWAs in the background? My question is are web notifications a good enough substitute for push notifications or is it that Web notifications cannot be triggered by a server and thus push notifications are still necessary?

推荐答案

网络通知是否适用于后台的 PWA?

Do web notifications work for PWAs in the background?

是的,他们在后台工作,即使网站关闭,感谢服务工作者.

Yes, they work in background, even when the website is closed, thanks to service workers.

当接收到推送信号时,会激活 Service Worker 并调用 JavaScript 回调.

When a push signal is received, the service worker is activated and a JavaScript callback is invoked.

网络通知是否足以替代推送通知

are web notifications a good enough substitute for push notifications

Web 通知与在后台传递消息的 W3C Push API 一起是真正的推送通知,即使在网站关闭时也可以传递.

Web notifications, together with the W3C Push API, that delivers the messages in background, are real push notifications, that can be delivered even when a website is closed.

是不是服务器不能触发Web通知,推送通知还是有必要的?

is it that Web notifications cannot be triggered by a server and thus push notifications are still necessary?

是的,可以使用 Push APIWebPush 协议在后台从您的服务器触发网络推送通知.

Yes, web push notifications can be triggered in background, from your server, using the Push API and WebPush protocol.

如果 iPhone 用户使用 Chrome,这是否意味着它们可以工作?

does it mean that they work if the iPhone user is using Chrome?

目前(2021 年第一季度),iPhone 不支持在任何浏览器上进行网络推送.

Currently (Q1 2021), iPhone doesn't support web push on any browser.

这篇关于PWA 的推送通知或 Web 推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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