Code Monkey home page Code Monkey logo

Comments (20)

DanJ210 avatar DanJ210 commented on July 21, 2024 17

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?

from web-push-codelab.

DanJ210 avatar DanJ210 commented on July 21, 2024 9

@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.

from web-push-codelab.

colepacak avatar colepacak commented on July 21, 2024 3

@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.

from web-push-codelab.

noobling avatar noobling commented on July 21, 2024 3

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?

from web-push-codelab.

TheSecurityBunker avatar TheSecurityBunker commented on July 21, 2024 2

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...

from web-push-codelab.

DanJ210 avatar DanJ210 commented on July 21, 2024 1

@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.

from web-push-codelab.

Danhiler avatar Danhiler commented on July 21, 2024 1

Had the same issue, used chrome canary to fix this

from web-push-codelab.

gauntface avatar gauntface commented on July 21, 2024

@varora1406 could you please explain a little more about what you mean by "when I launched a push from application tab in chrome"

from web-push-codelab.

gauntface avatar gauntface commented on July 21, 2024

Ah got you. @colepacak @varora1406 could you suggest any ways to improve the code to make this more obvious?

from web-push-codelab.

colepacak avatar colepacak commented on July 21, 2024

@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.

from web-push-codelab.

Abraham21 avatar Abraham21 commented on July 21, 2024

@DanJ210 did you solve this? I have the same problem right now.

from web-push-codelab.

RedSpeeds avatar RedSpeeds commented on July 21, 2024

@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

from web-push-codelab.

DanJ210 avatar DanJ210 commented on July 21, 2024

@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?

from web-push-codelab.

myakura avatar myakura commented on July 21, 2024

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

from web-push-codelab.

akonyer avatar akonyer commented on July 21, 2024

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.

from web-push-codelab.

kimdugong avatar kimdugong commented on July 21, 2024

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.

from web-push-codelab.

Acanguven avatar Acanguven commented on July 21, 2024

Works great on version 71.0.3578.80

from web-push-codelab.

annaelizabeth2019 avatar annaelizabeth2019 commented on July 21, 2024

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.

from web-push-codelab.

vergilius avatar vergilius commented on July 21, 2024

For anyone else struggling with the issue: make sure your push listener is in the service worker itself.

from web-push-codelab.

kha1989led avatar kha1989led commented on July 21, 2024

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:

  1. Open chrome://gcm-internals
  2. Start recording
  3. Send a test push notification to the browser
  4. Observe the logs

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

from web-push-codelab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.