Skip to content

Commit 0c5df00

Browse files
committed
Fix getting background notifications twice
1 parent 183e602 commit 0c5df00

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

frontend/public/firebase-messaging-sw.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@ importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js')
33

44
const urlParams = new URLSearchParams(location.search)
55
const firebaseConfig = Object.fromEntries(urlParams.entries())
6-
firebase.initializeApp(firebaseConfig)
76

8-
if (firebase.messaging.isSupported()) {
9-
const messaging = firebase.messaging()
10-
messaging.onBackgroundMessage((payload) => {
11-
const notificationTitle = payload.notification.title
12-
const notificationOptions = {
13-
body: payload.notification.body,
14-
tag: notificationTitle,
15-
icon: payload.notification?.image
16-
}
17-
self.registration.showNotification(notificationTitle, notificationOptions)
18-
})
19-
}
7+
firebase.initializeApp(firebaseConfig)
8+
firebase.messaging() // Listen to incoming notifications by initializing messaging

0 commit comments

Comments
 (0)