service-worker

I'm trying to make use of the service worker in create-react-app but I keep getting…wont register sw. Current env: development

自闭症网瘾萝莉.ら 提交于 2020-07-23 11:38:26
问题 I'm using create-react-app but the service worker isnt working. Im using localhost I'm trying to make this a PWA, i'm using the stock manifest file and service worker generated when you create-react-app, i've also rand npm run-script build and got the generated service-worker.js file. The problem is that I keep getting this in the console. wont register sw. Current env: development help? window.addEventListener("load", () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; if

I'm trying to make use of the service worker in create-react-app but I keep getting…wont register sw. Current env: development

梦想的初衷 提交于 2020-07-23 11:38:13
问题 I'm using create-react-app but the service worker isnt working. Im using localhost I'm trying to make this a PWA, i'm using the stock manifest file and service worker generated when you create-react-app, i've also rand npm run-script build and got the generated service-worker.js file. The problem is that I keep getting this in the console. wont register sw. Current env: development help? window.addEventListener("load", () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; if

Service Worker controllerchange never fires

◇◆丶佛笑我妖孽 提交于 2020-07-20 17:01:45
问题 I want to send a message to a service worker every time the page loads. The first time the page loads it calls register() and then listens for the "controllerchange" event on navigator.serviceWorker but this never fires. How do I know when I can start postMessaging a service worker? navigator.serviceWorker.register(swURL).then(function(){ var sw; if (navigator.serviceWorker.controller) { sw = navigator.serviceWorker.controller; sw.postMessage('ping'); return; } function onchange(){ sw =

Can not debug webapp on an Android phone using port-forwarding

谁都会走 提交于 2020-07-10 10:27:25
问题 I have a web app with service worker that is served from my Desktop, and I want to debug on an Android phone (Pixel3). On the desktop I'm using localhost which satisfies the secured connection (https) requirement for development purposes, and the page shows up with the secured padlock, and the service worker works correctly - good!. On the phone I can browse to the Desktop IP address (192.168.1.74) and the web app loads and responds fast (although without secure padlock, as expected). But on

Use ReadableStream with Response to return HTML from fetch event of Service Worker

♀尐吖头ヾ 提交于 2020-07-09 08:32:42
问题 I'm trying to return a stream for the HTML response in a service worker but the browser does not seem to be able to parse it (I'm using chrome for this test). So, this one works (in the fetch event): event.respondWith(new Response("<h1>Yellow!</h1>", { headers: { "Content-Type": "text/html" }})) But when I use a ReadableStream it no longer renders in the browser: const stream = new ReadableStream({ start(controller) { controller.enqueue("<h1>Yellow!</h1>") controller.close() } }) event

Use Asynchronous ReadableStream with Response to return HTML from fetch event of Service Worker

喜夏-厌秋 提交于 2020-07-08 20:38:29
问题 This question is similar to my other question but takes into account asynchronous nature inside the ReadableStream . This is my test code now: const stream = new ReadableStream({ start(c) { let i = 1 const t = setInterval(test, 5e2) function test() { c.enqueue("<h1>Yellow!</h1>") if (i++ === 5) { clearInterval(t) c.close() } } } }) event.respondWith(new Response(stream, {headers: {"content-type": "text/html"}})) The above code is not rendered by the browser and I'm not sure why. According to

Can not debug service-worker on an Android phone

谁说胖子不能爱 提交于 2020-07-01 07:39:40
问题 I have a web app with service worker that is served from my Desktop, and I want to debug on an Android phone (Pixel3). On the desktop I installed a self-trusted CA to satisfy the secured connection (https), and the page shows up with the secured padlock - good!. But on the phone, I cannot get the secured padlock to show up. (I can debug the web app by connecting the phone via USB cable, selecting inspect for the required tab, for the Pixel 3 XL device, in chrome://inspect/#devices , and

Can not debug service-worker on an Android phone

二次信任 提交于 2020-07-01 07:39:25
问题 I have a web app with service worker that is served from my Desktop, and I want to debug on an Android phone (Pixel3). On the desktop I installed a self-trusted CA to satisfy the secured connection (https), and the page shows up with the secured padlock - good!. But on the phone, I cannot get the secured padlock to show up. (I can debug the web app by connecting the phone via USB cable, selecting inspect for the required tab, for the Pixel 3 XL device, in chrome://inspect/#devices , and

Can not debug service-worker on an Android phone

删除回忆录丶 提交于 2020-07-01 07:39:02
问题 I have a web app with service worker that is served from my Desktop, and I want to debug on an Android phone (Pixel3). On the desktop I installed a self-trusted CA to satisfy the secured connection (https), and the page shows up with the secured padlock - good!. But on the phone, I cannot get the secured padlock to show up. (I can debug the web app by connecting the phone via USB cable, selecting inspect for the required tab, for the Pixel 3 XL device, in chrome://inspect/#devices , and

Pass custom data to service worker sync?

时光总嘲笑我的痴心妄想 提交于 2020-06-26 14:05:14
问题 I need to make a POST request and send some data. I'm using the service worker sync to handle offline situation. But is there a way to pass the POST data to the service worker, so it makes the same request again? Cause apparently the current solution is to store requests in some client side storage and after client gets connection - get the requests info from the storage and then send them. Any more elegant way? PS: I thought about just making the service worker send message to the