angular / angular/angularfire

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

Đang mở
#3,469 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
7.8k
Fork
2.2k
Merge trung bình
22 giờ 28 phút
Pull request đã merge (30 ngày)
6

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách so sánh thiết lập onMessage của service với đăng ký onBackgroundMessage trong firebase-messaging-sw.js, sau đó tái hiện hành vi với PWA ở chế độ nền. Được xem là hoàn tất khi handler dự kiến được thiết lập và hành vi khi nhấn vào thông báo được sửa hoặc giới hạn được ghi rõ trong tài liệu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, firebase, typescript
Lĩnh vực
frontend, web-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
28/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.