firebase-js-sdk
firebase-js-sdk copied to clipboard
FR: Allow modification of the notification object before it is shown
Operating System
MacOS 13.3.1 on an M1 pro chip
Browser Version
Chrome 115.0.5790.170
Firebase SDK Version
9.23.0
Firebase SDK Product:
Auth, Firestore, Functions, Messaging
Describe your project's tooling
We are deploying a PWA using firebase and using FCM to send push notifications.
Describe the problem
Currently, if you create a campaign to be sent to a web app, it does not allow you to provide certain fields (namely an icon url). It would be nice to be able to intercept the notification object before it is displayed so that I can make sure an icon is specified. I believe this was supported in the old firebase messaging trough messaging.setBackgroundMessageHandler()
but there does not appear to be an equivalent in the new modular api.
Steps and code to reproduce issue
I would like to be able to do something like the following:
const app = initializeApp(firebaseConfig)
const messaging = getMessaging(app)
onBackgroundMessage(messaging, (message) => {
if (message.notification && !message.notification.icon) {
message.notification.icon = '/icon512.png'
}
})