Closed vaibhavarora14 closed 3 years ago
@varora1406 could you please explain a little more about what you mean by "when I launched a push from application tab in chrome"
@varora1406, the push event listener needs to go in sw.js, not main.js. It got me too.
It makes sense because self
refers to the service worker itself.
Ah got you. @colepacak @varora1406 could you suggest any ways to improve the code to make this more obvious?
@gauntface, after looking back at the docs, you're pretty clear on the fact that the service worker code belongs in sw.js
, but I blew right past it as I was going through the tutorial.
One thing that may help is to add one of those slick blue callouts with the blue star (with the "note" CSS class) right after the initial service worker code reminding users that sw.js
is the home for all of the service worker event listeners.
Thanks for the great docs.
Everything was working fine up until adding the event listener to sw.js. I've added the code but the push button in dev tools does not send a push. The event isn't triggered at all whatsoever. Doesn't matter if I unregister and restart the site. Why wouldn't the event listener be working?
@DanJ210 did you solve this? I have the same problem right now.
@Abraham21 On my personal computer I was able to send a push from a push service but not the "Push" button in dev tools. So the event listener seems to be working but the "Push" button in dev tools seems to not be working.
@DanJ210 Did you find a fix at my end the push button in the chrome devtools also seems to be not functioning when i try to send a push message using a site it works but not when i try it using chrome devtools
@TheCreeperCow Nope, unfortunately not. It seems like the push button in dev tools doesn't work for anyone here. Or if it does then it's not working for this type of project. Though the code is an event listener so it seems as if dev tools isn't emiting the proper event or an event at all. Idk I'm just guessing.
If you look at the pictures from the docs https://developers.google.com/web/ilt/pwa/tools-for-pwa-developers#update they are different to what the latest chrome interface is maybe this worked on older chrome?
@noobling it's very possible. We are using Google's own training so you'd think there'd be some heads up to Google people if a major tool is changing. Have you worked through this course?
I just run into the same issue. It looks like a bug in DevTools.
849241 - Service worker's Push/Sync locally triggered events don't work - chromium - Monorail https://bugs.chromium.org/p/chromium/issues/detail?id=849241
Getting the exact same behavior. I can not use the Push button to test my service worker.
All other events fire no problem (Install, Activate) but push doesn't even fire at all using the "Push" test button.
Wasted about 3 hours to find out Chrome is broke. Download Chrome Dev. Latest version has the button fixed. Can run it along side your normal Chrome, so no need to uninstall anything...
Had the same issue, used chrome canary to fix this
Check your chrome version now. Version 71.0.3578.80would be work correctly. Previous version(70.0.3538.110?) of chrome didn't work in my case.
Works great on version 71.0.3578.80
Similar issue, here. Sometimes notifications do not show on some systems. My Chrome is 78.0.3904.70 so is my product manager's, but he cannot get the notifications to show up. I can see the service-worker receive the payload and everything.
For anyone else struggling with the issue: make sure your push listener is in the service worker itself.
If you are sure your service worker is registered in the browser but your 'push' event is not getting triggered, you can debug all incoming push notifications to Google Chrome by doing the following:
chrome://gcm-internals
The server was getting a 201 on the push request and the browser threw no errors in the console log. However, I was having a decryption issue. The browser was receiving the push notification but failed to decrypt it: AES-GCM decryption failed
.
Helpful Source: https://developers.google.com/web/fundamentals/push-notifications/common-issues-and-reporting-bugs
Code: