简体   繁体   English

未安装应用程序时 PWA 推送通知不起作用

[英]PWA push notifications not working when app is not installed

Are push notification supposed to work only if the PWA is installed?推送通知是否应该仅在安装 PWA 时才起作用? If I load the app in android chrome browser, push notifications are not displayed at all (background or having the site opened) even they come thru the wire.如果我在 android chrome 浏览器中加载应用程序,则推送通知根本不会显示(背景或打开网站),即使它们是通过网络发送的。

If I install the app, all notifications are displayed properly (background or focused app).如果我安装该应用程序,所有通知都会正确显示(背景或焦点应用程序)。

Is this normal a behaviour or something wrong in the implementation?这是正常的行为还是实施中有问题?

This is as expected.这正如预期的那样。

The service worker runs on a separate thread than the one used by your application.服务工作者在与您的应用程序使用的线程不同的线程上运行。 This is the reason why your web app can still receive and display notifications even if you (or your user) is not currently visiting the web site.这就是为什么您的 web 应用程序仍然可以接收和显示通知的原因,即使您(或您的用户)当前没有访问 web 站点。

Therefore if the PWA is not installed (meaning the SW is not running on the client side), there is no code waiting for the incoming notifications.因此,如果未安装 PWA(意味着 SW 未在客户端运行),则没有代码等待传入通知。

I wrote an article about service workers , if you want to deepen the PWAs topic.如果您想深入了解 PWA 主题, 我写了一篇关于 service workers 的文章


UPDATE更新

  • There is an article specifically from OneSignal about not receiving Push Notifications on Android, maybe you can find some hints. OneSignal 专门有一篇关于在 Android 上没有收到推送通知的文章,也许你可以找到一些提示。 If you check the OneSignal dashboard, can you see your client registered there?如果您检查 OneSignal 仪表板,您能看到您的客户在那里注册吗?

  • [ This point is for other users landing to this question ] [这点是给其他用户登陆这个问题的]
    If your browser does not show web notifications, you can verify on "Can I Use" web site that your browser version supports notifications and push API and eventually update it.如果您的浏览器没有显示 web 通知,您可以在“我可以使用”web 网站上验证您的浏览器版本是否支持通知推送 API并最终更新它。

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

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