v0.12.5 FCM bug fixes

This commit is contained in:
2026-03-23 12:07:52 -04:00
parent f9024a6f3a
commit 048abcfbfd
5 changed files with 34 additions and 16 deletions

View File

@@ -8,6 +8,7 @@
"orientation": "any",
"background_color": "#ffffff",
"theme_color": "#1a73e8",
"gcm_sender_id": "126479377334",
"icons": [
{
"src": "/icons/icon-192.png",
@@ -22,18 +23,11 @@
"purpose": "maskable"
},
{
"purpose": "maskable",
"purpose": "any maskable",
"src": "/icons/icon-512-maskable.png",
"sizes": "512x512",
"type": "image/png"
},
{
"purpose": "any",
"src": "/icons/icon-512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"min_width": "320px"

View File

@@ -93,13 +93,37 @@ firebaseConfigPromise.then(() => {
}
});
// ── Raw push event (fallback diagnostic) ─────────────────────────────────────
// Fires for every push event BEFORE the Firebase SDK handles it.
// Log it so chrome://inspect shows whether the SW is even waking up.
// ── Raw push event (fallback for Android) ─────────────────────────────────────
// Android Chrome sometimes doesn't properly trigger Firebase's onBackgroundMessage
// This fallback ensures notifications are displayed even if Firebase SDK fails
self.addEventListener('push', (event) => {
console.log('[SW] push event received, hasData:', !!event.data, 'text:', event.data?.text?.()?.slice(0, 120));
// Note: Firebase compat SDK registers its own push listener and handles display.
// This listener is diagnostic only — do not call showNotification() here.
// Try to handle the push event directly as a fallback
if (event.data) {
try {
const data = event.data.json();
console.log('[SW] Push data parsed:', JSON.stringify(data));
// If this is a Firebase message with data payload, show notification
if (data.data || (data.title && data.body)) {
const notificationData = data.data || data;
return showRosterChirpNotification(notificationData);
}
} catch (e) {
console.warn('[SW] Failed to parse push data:', e);
// Try to show a basic notification with the raw text
const text = event.data.text();
if (text) {
return self.registration.showNotification('RosterChirp', {
body: text.slice(0, 100),
icon: '/icons/icon-192.png',
badge: '/icons/icon-192-maskable.png',
tag: 'rosterchirp-fallback',
});
}
}
}
});
// ── Notification click ────────────────────────────────────────────────────────