When pwa is in background, the serviceworker still uses onMessage not onBackgroundMessage!
- 主要言語
- TypeScript
- スター
- 7.8k
- フォーク
- 2.2k
- 平均マージ
- 22時間 28分
- マージ済み PR(30日)
- 6
説明
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.
コントリビューションガイド
調査の方向性
まず、サービスの onMessage のセットアップと firebase-messaging-sw.js の onBackgroundMessage の登録を比較し、その後、PWA をバックグラウンドで実行して動作を再現します。期待される handler が確立され、通知をタップしたときの動作が修正されるか、制限事項が明確に文書化されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, firebase, typescript
- 領域
- frontend, web-dev
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 28/100