最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why is Service Worker not running on Chrome for Android? - Stack Overflow

programmeradmin7浏览0评论

Currently I'm trying to build a web app using the Samsung Tab A. I thought this device would support Service Workers, cause following Can I Use says Chrome for Android 55 is required to run SW.

The tablet is running Android 6.0.1 (no more updates available) and Chrome 55.0.2, but unfortunately when the code shown below runs, the 'no sw' alert pops up.. The SW works fine in Chrome on desktop (mac OS).

if('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js').then((registration) => {
    alert('sw');
    console.log('ServiceWorker successful, scope: ', registration.scope);
  }).catch((err) => {
    alert('no sw');
    console.log('ServiceWorker failed: ', err);
  });
}

Am I doing something wrong, or is it not possible to run SW on this kind of tablet? What else is needed if Chrome 55 isn't enough? I think there is some lack of information about this topic since I can't find the answer on this .. :(

Thanks in advance!

EDIT: I'd already enable multiple flags via chrome://flags without any success..

Currently I'm trying to build a web app using the Samsung Tab A. I thought this device would support Service Workers, cause following Can I Use says Chrome for Android 55 is required to run SW.

The tablet is running Android 6.0.1 (no more updates available) and Chrome 55.0.2, but unfortunately when the code shown below runs, the 'no sw' alert pops up.. The SW works fine in Chrome on desktop (mac OS).

if('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js').then((registration) => {
    alert('sw');
    console.log('ServiceWorker successful, scope: ', registration.scope);
  }).catch((err) => {
    alert('no sw');
    console.log('ServiceWorker failed: ', err);
  });
}

Am I doing something wrong, or is it not possible to run SW on this kind of tablet? What else is needed if Chrome 55 isn't enough? I think there is some lack of information about this topic since I can't find the answer on this .. :(

Thanks in advance!

EDIT: I'd already enable multiple flags via chrome://flags without any success..

Share Improve this question edited Jan 14, 2017 at 13:23 ronnyrr asked Jan 14, 2017 at 12:38 ronnyrrronnyrr 1,5514 gold badges29 silver badges48 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 13

I was using ngrok to serve my webapp locally to my tablet. Did forget to use https..

Go to chrome://flags and add the url like http://localhost:3000/ to the unsafe input

if you don't know just follow the picture bellow.

https://i.ibb.co/Tvwv6VN/Screenshot-20220727-223110.jpg

after this re launch your chrome or any browser.

发布评论

评论列表(0)

  1. 暂无评论