简体   繁体   English

在非 PWA 网络应用程序中弹出“添加到主屏幕”

[英]“Add to Home Screen” pop up in a non PWA web app

Is it possible to have a pop up for "Add to home Screen" in a web app that is not a PWA app.?是否可以在非 PWA 应用程序的网络应用程序中弹出“添加到主屏幕”。? If yes then how to go about it.如果是,那么如何去做。 I tried some solutions from the below link in stackoverflow but it seems it only works via the browser option "Add to home screen" and is not triggering a Pop Up.我尝试了以下 stackoverflow 链接中的一些解决方案,但它似乎只能通过浏览器选项“添加到主屏幕”起作用,并且不会触发弹出窗口。

Quoted from MDN.引用自 MDN。

How do you make an app A2HS-ready?您如何使应用程序支持 A2HS? To enable your app to be added to a Home screen, it needs the following:要将您的应用添加到主屏幕,它需要以下内容:

  • To be served over HTTPs — the web is increasingly being moved in a more secure direction, and many modern web technologies (A2HS included) will work only on secure contexts.通过 HTTP 提供服务——网络正越来越多地朝着更安全的方向发展,许多现代网络技术(包括 A2HS)只能在安全的上下文中工作。
  • To have a manifest file with the correct fields filled in, linked from the HTML head.要有一个清单文件,其中填写了正确的字段,从 HTML 头链接。
  • To have an appropriate icon available for displaying on the Home screen.有一个适当的图标可用于在主屏幕上显示。
  • Chrome additionally requires the app to have a service worker registered (eg, so it can function when offline). Chrome 还要求应用程序注册一个 service worker(例如,这样它可以在离线时运行)。

PWA PWA

In order to call a Web App a PWA, technically speaking it should have the following features:为了将 Web App 称为 PWA,从技术上讲,它应该具有以下特征:

  • Secure contexts (HTTPS)安全上下文 (HTTPS)
  • Service workers服务人员
  • Manifest file清单文件

As we can clearly tell from the above quotes, Add To Home Screen feature only differentiates in one way from a PWA, Service Workers .从上面的引述中我们可以清楚地看出,添加到主屏幕功能与 PWA、 Service Workers仅以一种方式区分。 In Chrome though, you also need a service worker to enable A2HS.但是,在 Chrome 中,您还需要一个 Service Worker 来启用 A2HS。 Since Chrome is the most popular browser and most of the other browsers are also based on Chromium, it is safe to say that the A2HS feature is only available for PWAs to most of the users.由于 Chrome 是最受欢迎的浏览器,并且大多数其他浏览器也基于 Chromium,因此可以肯定地说,A2HS 功能仅适用于大多数用户的 PWA。

See:看:

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

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