如何通过单击推送通知来启动PWA(渐进式Web应用程序)打开?

问题描述:

遵循此示例,我看到PWA如何打开URL,但是如何使用推送通知来启动应用程序本身?不在浏览器中,而是在全屏版本PWA中.

Following this example, I see how PWA can open urls but how can I use push notification to launch the app itself? Not in the browser but the full screen version PWA.

这是由浏览器控制的.另外,在决定打开一个窗口时,可能值得检查一下所需的目标URL是否为已经在其他标签页/窗口中打开,因此您可以根据情况集中或打开它.请在此在此处预订一些代码示例.

This is controlled by the browser. In addition when deciding to open a window it might be worth checking if the desired target URL is already open in a different tab/window so you can focus or open it, depending on the situation. Check this book here for some code samples.

例如,在Chrome浏览器中,如果用户在每次单击该Web应用程序图标时将其清单中带有独立"的Web应用添加到其主屏幕,则该应用将在没有网址栏的情况下打开.

For example in Chrome, if a user adds a web app to their homescreen with "standalone" in their manifest when ever the user clicks the web apps icon it will open without the URL bar.

当收到推送消息并打开了相同的Web应用程序时,如果用户从主屏幕图标(当前最近10天)最近"打开了Web应用程序,则不会显示URL栏.如果用户在这段时间内未使用主页图标,则会打开一个通知单击,其中显示URL栏.

When a push message is received and that same web app is opened, the URL bar will not be displayed if the user has "recently" opened the web app from the homescreen icon (Currently in the last 10 days). If the user hasn't used the home icon within that time period, a notification click will open with the URL bar displayed.

请参阅此处有关此Chrome问题的更多信息 :

具体:

必须将网络应用添加到主屏幕,并且可以在 独立模式,并且已从主屏幕中打开 最近十天.如果不满足这些条件中的任何一个,则 通知将恢复为现有行为.

The web app must be added to home screen, capable of opening in standalone mode, and have been opened from the home screen within the last ten days. If any of these conditions are not met, the notification will fall back to the existing behaviour.

值得注意的是,PWA与浏览器本身并不是正确的思考方式.您总是在浏览器中启动,只是以不同的模式启动,例如独立"与浏览器".

It's also worth noting that PWA vs Browser itself isn't the right way of thinking of this. You are always launching in the Browser, just in different modes, "standalone" vs "browser" for example.

PWA(渐进式Web应用程序)在很大程度上是一个术语,用于描述使用一组API来通过新的Web技术(即服务工作者,推送,Web应用程序清单等)获得良好的用户体验.

PWA (Progressive Web Apps) is largely a term to describe a use of a set of API's to make a good user experience with new web technologies (i.e. service workers, push, web app manifest etc).