Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GAURAVCHAWLA1808
Copy link

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

Copy link

google-cla bot commented Feb 11, 2025

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.

@GAURAVCHAWLA1808 GAURAVCHAWLA1808 changed the title Complete Web Push Example with Non-Interactive Subscription Enhance Web Push Example with Non-Interactive Subscription & Auto-Activation in Service Worker Feb 11, 2025
@oliverdunk
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complete web push example with non-interactive subscription
2 participants