Skip to content

FCM title is undefined #9086

@bangln

Description

@bangln

Operating System

any ios version

Environment (if applicable)

reactjs

Firebase SDK Version

firebase version 10.14.0

Firebase SDK Product(s)

Messaging

Project Tooling

react app

Detailed Problem Description

notification display undefined

Steps and code to reproduce issue

I got error when send 3 times notification on IOS and I try to add this code:
self.addEventListener('push', function (event) {
event.stopImmediatePropagation();
console.log('[Service Worker] Push Received.');
const payload = event.data.json();
const notificationTitle = payload.notification.title;
const notificationOptions = {
...payload.notification,
data: {
...payload.data,
click_url: payload.notification.click_action,
}
};
event.waitUntil(
self.registration.showNotification(notificationTitle, notificationOptions)
);
});

self.addEventListener('notificationclick', function (event) {
event.preventDefault();
console.log('Notification click Received.', event.notification.data);

event.notification.close();

event.waitUntil(
    clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (clientList) {
        // Check if there is already a window/tab open with the target URL
        for (let i = 0; i < clientList.length; i++) {
            let client = clientList[i];
            if (client.url.startsWith(event.notification.data.click_url) && client.focus) {
                client.focus();
                client.postMessage(event.notification.data);
                return;
            }
        }
        // If not, then open a new window/tab with the target URL
        if (clients.openWindow) {
            clients.openWindow(event.notification.data.click_url).then((windowClient) => {
                windowClient.postMessage(event.notification.data);
            });
        }
    })
);

});

and now message display undefined

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions