Menu

#1410 Enhance Web Push Example with Non-Interactive Subscription & Auto-Activation in Service Worker

open
nobody
None
2025-03-04
2025-02-11
Anonymous
No

Originally created by: GAURAVCHAWLA1808

This PR fixes Issue [#1408] by automating the push subscription process in the cookbook.push extension. Previously, users had to manually subscribe via the Service Worker DevTools. This update ensures the subscription is created automatically when the Service Worker activates.

Changes Implemented
background.js
Added event.waitUntil(subscribeUserVisibleOnlyFalse()); in the activate event to auto-subscribe users.
Improved logging for debugging.
Ensured userVisibleOnly = true for push notifications.
manifest.json
Added "gcm_sender_id": "103953800507" for better push compatibility.
popup.js
Improved error handling for subscription failures.
Added clear logs when subscribing/unsubscribing.
README.md
Updated instructions to include automatic subscription.
Added a template for send-push.js to help test push messages.
This update ensures a fully functional, real-world web push example without requiring manual DevTools interaction.

Fixes [#1408]

Related

Tickets: #1408
Tickets: #1422
Tickets: #1423
Tickets: #1424

Discussion

  • Anonymous

    Anonymous - 2025-02-11

    Originally posted by: google-cla[bot]

    Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

    View this failed invocation of the CLA check for more information.

    For the most up to date status, view the checks section at the bottom of the pull request.

     
  • Anonymous

    Anonymous - 2025-02-12

    Originally posted by: oliverdunk

    @patrickkettner, is this one you would like to look at? If not, feel free to assign it to me.

     
  • Anonymous

    Anonymous - 2025-02-27

    Originally posted by: GAURAVCHAWLA1808

    Hi @oliverdunk , I would appreciate your guidance on this PR and any improvements I can make. Your insights would be valuable in ensuring everything aligns well with the project.

    Additionally, I’m eager to contribute more—could you suggest other issues or areas where I can help? Looking forward to your guidance.
    Thanks!

     
  • Anonymous

    Anonymous - 2025-03-04

    Originally posted by: GAURAVCHAWLA1808

    Thanks for opening this, and sorry for the delay leaving a review. Generally we want PRs to be well scoped and solve a single problem - in this case it's unclear what this PR's main goal is, as it does a lot of things:

    • Changes logging
    • Introduces a popup
    • Automatically subscribes on service worker startup
    • Significantly changes the README
    • Changes how the API key is provided

    It would be great if you could choose one of those things and make the PR focused on that. We can then definitely review work on the others in additional PRs :)

    Thanks for your feedback, Oliver! I understand the concern regarding the PR scope. I'll separate the changes into multiple PRs, each focusing on a single issue .

     

Log in to post a comment.