angular / angular/angularfire

When pwa is in background, the serviceworker still uses onMessage not onBackgroundMessage!

Abierto
#3,469 7 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
7.8k
Forks
2.2k
Merge medio
22 h 28 min
PR fusionados (30 d)
6

Descripción

Hello,

when I send a push notification to my app, the onMessage method is called even if it is in the background! Actually, the onBackgroundMessage should then be called, right? The problem now is that when I tap on the message box in Android, the Progressive Web Application is not brought to the foreground. Apparently Android thinks that the app is in the foreground? The message box disappears when I tap on it and the number of incoming messages also disappears from the app icon.

Is there any way to fix this?

The onMessage is defined in a service
`this.message$ = new Observable(sub => onMessage(this.messaging, it => sub.next(it))).pipe(
tap(payload => {this.print.info('MessagingService initFCMMessaging() FCM fmessage', { payload });})
);`

The onBackgroundMessage is defined in the firebase-messaging-sw.js with static text.

`messaging.onBackgroundMessage(function(payload) {
// Customize notification here
const notificationTitle = 'My title';
const notificationOptions = {
body: 'My Bodytext',
icon: '/firebase-logo.png' || '/assets/icons/icon-72x72.png'
};

self.registration.showNotification(notificationTitle, notificationOptions);
});`

I only noticed this because I defined a static text for the background message.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza comparando la configuración de onMessage del servicio con el registro de onBackgroundMessage en firebase-messaging-sw.js y, a continuación, reproduce el comportamiento con la PWA en segundo plano. Se considera terminado cuando el handler esperado está establecido y el comportamiento al tocar la notificación se ha corregido o la limitación está claramente documentada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, firebase, typescript
Área
frontend, web-dev
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
28/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.