有没有一种使用渐进式Web应用程序(PWA)添加徽章通知的方法?

问题描述:

我正在开发一个渐进式Web应用程序(PWA),该应用程序最终将向用户发送通知.

I'm developing a progressive web application (PWA) that will eventually send notifications to users.

我已经知道我能够发送推送通知(像任何常规应用一样),如以下博客文章所述: https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/?hl=zh-CN -我们.

I already know I'm able to send push notifications (like any regular app), as explained in the following blog post: https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/?hl=en-us.

我还知道我可以通过创建一个简单的清单文件(

I also know that I can add a PWA to the home screen, by creating a simple manifest file (https://developers.google.com/web/updates/2014/11/Support-for-installable-web-apps-with-webapp-manifest-in-chrome-38-for-Android).

但是,在将应用程序显示在主屏幕中之后,我想添加一个提示"框,给用户,让他们知道他们必须访问该应用程序.做到这一点的一种好方法是做一些类似于徽章通知"的事情. (如下图的Facebook图标所示).

However, after having the app in home screen, I would like to add a "hint" to users, letting they know that they have to access the application. A great way to do that is doing something like a "badge notification" (as showed in Facebook icon on the image below).

是否可以使用渐进式Web应用程序添加这种行为?

Is it possible to add this kind of behavior using progressive web applications?

Google最近发布了一篇帖子,解释了所谓的"Badging for App Icons",这很令人兴奋:

Google recently launched a post explaining about the so called "Badging for App Icons", which is pretty exciting:

https://developers.google.com/web/updates /2018/12/badging-api

  • https://bugs.chromium.org/p/chromium/issues/detail?id=719176&desc=2
  • https://bugs.chromium.org/p/chromium/issues/detail?id=685159
  • https://github.com/mgiuca/badging/blob/master/explainer.md
  • https://docs.google.com/document/d/1AmX53h-gk8wN7LPMi_Mq7fsIMgsMKRD6zKa1Ymxxvvc/edit#

如Josh Lee在

As Josh Lee pointed out in Is there a way to add badge notifications using progressive web apps (PWA)?, there are some discussions about the subject on the chromium team.

查看讨论:

仅供参考,通知指示器被推到M-71.

FYI, the notification indicators are being pushed to M-71.

感谢大家的注意.这对我们来说很好,因为尽管我们希望在M70的标记后提供可测试的功能,但我们无法(至少)在M71之前无法启动API.

Thanks for the heads up. That's fine for us because while we hope to have this testable behind a flag in M70, there's no way we'll be launching the API before (at least) M71.

因此,也许至少在目前,似乎无法为PWA添加徽章通知,但也许将来我们可以做到这一点.

So, maybe, at least for now, it seems that it's not possible to add badge notifications for PWAs, but maybe in the future we'll be able to do that.

更新2020: 选中此方法回答最新信息:

App Badging API可在Windows和macOS(Chrome 81或更高版本)上运行.也已确认它可以在Edge 84或更高版本上使用.目前正在开发对Chrome操作系统的支持,并将在以后的Chrome版本中提供该支持.在Android上,不支持Badging API.相反,当出现未读通知时,Android会自动为已安装的Web应用程序在应用程序图标上显示徽章,就像Android应用程序一样.

The App Badging API works on Windows, and macOS, in Chrome 81 or later. It has also been confirmed to work on Edge 84 or later. Support for Chrome OS is in development and will be available in a future release of Chrome. On Android, the Badging API is not supported. Instead, Android automatically shows a badge on app icon for the installed web app when there is an unread notification, just as for Android apps.

原始答案:

看起来像是在路线图上,可能在M71的标志后面.

Looks like this is on the roadmap, possibly behind a flag in M71.

crbug.com/719176
crbug.com/685159

(因此,是10月下旬的beta(计划).该错误没有其他活动可证实了这一点,但是大多数WebAPK工作不是针对FWIW的公共bug.)

(So, a late October beta (schedule). There's no other activity on the bug to corroborate that, but most of the WebAPK work was not on public bugs, FWIW.)