@alutsu wrote:
I’ve searched a lot for this problem that I’m stuck on for a week. I have an Ionic PWA project that receive some notifications from firebase, I can receive the notifications with no problem and can get the payload on foreground (app is open), but I cant get the payload when the app is closed and I don’t figure out what is goning on, so I came here to ask the masters to help me.
messaging.setBackgroundMessageHandler(function(payload) { var notificationTitle = 'Teste'; var notificationOptions = { body: 'Background Message body.', tag: 'campanhas', data: payload.data, icon: 'https://firebasestorage.googleapis.com/v0/b/hemotomobile-edeb9.appspot.com/o/logo.png?alt=media&token=4a9fc487-b8cf-4d3c-875c-774454ff6f50' }; return self.registration.showNotification(notificationTitle, notificationOptions); }); self.addEventListener('notificationclick', function(event) { event.notification.close(); event.waitUntil(clients.matchAll({ type: "window" }).then(function(clientList) { for (var i = 0; i < clientList.length; i++) { var client = clientList[i]; if (client.url == '/' && 'focus' in client) return client.focus(); } if (clients.openWindow) return clients.openWindow('/'); })); });and on my provider for the notifications, I use this code:
public receiveMessage() { console.log('notification') this.messaging.onMessage((payload) => { console.log('payload',payload) }); }I call this provider on my tabs-page:
ionViewDidLoad(){ this.notification.receiveMessage() }So, can anyone help me to get the payload when the PWA is closed?
Posts: 1
Participants: 1