当web Service 和 Manifest 被浏览器安装完后,正常情况下,浏览器会提醒用户可将网页安装到桌面。但是通常浏览器都会限制提醒。这时候我们需要手动唤醒浏览器询问用户是否安装到桌面 beforeinstallprompt
beforeinstallprompt 事件
window.addEventListener('beforeinstallprompt', function(event) { // 监听到可安装事件,进行触发提醒用户setTimeout(function() {event.prompt()event.userChoice //判断用户是否安装.then(function(e) {install = true}) }, 2000)}, { once: true })