https://abo-deg.surge.sh/survey/background https://github.com/strongharris/sample (位于src内的sw.js,主要入口点:src/index.js,webpack.config)警报消息通过桌面显示,但不在移动浏览器上显示.我想念什么吗?是否有其他方法为移动Web应用程序设置服务工作者?任何资源,技巧或猜测都将不胜感激.解决方案我认为答案很简单.在手机上键入 abo-deg.surge.sh 时,服务器不会自动将您转移到 https://abo-deg.surge.sh .我可以通过使用https://键入完整的URL在Chrome Mobile上运行它 Service Worker API仅适用于通过HTTPS运行的网站,因为在中间攻击中对人开放的修改过的网络请求确实很糟糕 https://developer.mozilla.org/zh-CN/docs/Web/API/Service_Worker_API 请记住,您的代码只能在这些浏览器上运行,所以不要希望它可以在iOS上运行I set up a service worker for a static web application that needs to work on mobile phones. I'm using react/webpack2 for this application.Service Worker installs and works greatly when I open the application via desktop, but when I try to visit the application through mobile, it does not install.When SW finishes installing, it gives you an alert message ("onInstalled");https://abo-deg.surge.sh (here is an example)https://abo-deg.surge.sh/survey/backgroundhttps://github.com/strongharris/sample (sw.js located inside src, main entrypoint: src/index.js, webpack.config)The alert message shows up via desktop, but not on mobile browsers.Am I missing something? Is there a different way to set up a service worker for mobile web applications? Any resources, or tips, or guesses would be greatly appreciated. 解决方案 I think the answer is pretty simple. Your server does not automatically transfer you to https://abo-deg.surge.sh when you type abo-deg.surge.sh on your mobile.I was able to run it on Chrome Mobile by typing full URL with https://Service worker API is available only for websites running over HTTPS, because Having modified network requests wide open to man in the middle attacks would be really bad https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_APIPlease keep in mind, that your code will work only on these browsers, so don't expect it to work on iOS 这篇关于Service Worker不适用于移动Web(Chrome,Firefox,IE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-24 12:36