Skip to content

Commit

Permalink
fix(firebase_messaging, web): Define scope for 'firebase-messaging-sw…
Browse files Browse the repository at this point in the history
….js' on registration (#12639)
  • Loading branch information
AnayShri committed Apr 22, 2024
1 parent b01c282 commit 02c26b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion docs/cloud-messaging/receive.md
Expand Up @@ -208,7 +208,9 @@ Next, the worker must be registered. Within the entry file, **after** the `main.
// Service workers are supported. Use them.
window.addEventListener('load', function () {
// Register Firebase Messaging service worker.
navigator.serviceWorker.register('firebase-messaging-sw.js');
navigator.serviceWorker.register('firebase-messaging-sw.js', {
scope: '/firebase-cloud-messaging-push-scope',
});

// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
Expand Down
Expand Up @@ -23,7 +23,9 @@
// Service workers are supported. Use them.
window.addEventListener('load', function () {
// Register Firebase Messaging service worker.
navigator.serviceWorker.register('firebase-messaging-sw.js');
navigator.serviceWorker.register('firebase-messaging-sw.js', {
scope: '/firebase-cloud-messaging-push-scope',
});

// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
Expand Down
4 changes: 3 additions & 1 deletion tests/web/index.html
Expand Up @@ -51,7 +51,9 @@
// Service workers are supported. Use them.
window.addEventListener('load', function () {
// Register Firebase Messaging service worker.
navigator.serviceWorker.register('firebase-messaging-sw.js');
navigator.serviceWorker.register('firebase-messaging-sw.js', {
scope: '/firebase-cloud-messaging-push-scope',
});

// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
Expand Down

0 comments on commit 02c26b3

Please sign in to comment.