angular / angular/angularfire

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

Aberta
#3,469 7 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
7.8k
Forks
2.2k
Merge médio
22h 28min
PRs com merge (30d)
6

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Comece comparando a configuração de onMessage do serviço com o registro de onBackgroundMessage em firebase-messaging-sw.js e, em seguida, reproduza o comportamento com a PWA em segundo plano. A tarefa estará concluída quando o handler esperado estiver estabelecido e o comportamento ao tocar na notificação for corrigido ou a limitação estiver claramente documentada.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
angular, firebase, typescript
Domínio
frontend, web-dev
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
28/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.