v0.12.8 FCM bug fix
This commit is contained in:
@@ -76,10 +76,21 @@ function showRosterChirpNotification(data) {
|
||||
}
|
||||
|
||||
// ── FCM background messages ───────────────────────────────────────────────────
|
||||
// Server sends notification+data messages (mirrors the working fcm-app pattern).
|
||||
// payload.notification carries title/body; payload.data carries url/groupId.
|
||||
// Fallback to payload.data.title/body supports any older data-only messages still
|
||||
// in-flight during a deployment transition.
|
||||
if (messaging) {
|
||||
messaging.onBackgroundMessage((payload) => {
|
||||
console.log('[SW] onBackgroundMessage received, data:', JSON.stringify(payload.data));
|
||||
return showRosterChirpNotification(payload.data || {});
|
||||
console.log('[SW] onBackgroundMessage received:', JSON.stringify({ notification: payload.notification, data: payload.data }));
|
||||
const n = payload.notification || {};
|
||||
const d = payload.data || {};
|
||||
return showRosterChirpNotification({
|
||||
title: n.title || d.title || 'New Message',
|
||||
body: n.body || d.body || '',
|
||||
url: d.url || '/',
|
||||
groupId: d.groupId || '',
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.warn('[SW] Firebase messaging not initialised — push notifications disabled');
|
||||
|
||||
Reference in New Issue
Block a user