правки
This commit is contained in:
gofnnp 2023-03-08 01:11:58 +04:00
parent 5152d9ad30
commit 699db43b39
2 changed files with 14 additions and 5 deletions

View File

@ -84,11 +84,15 @@ export class MessagingService {
receiveMessage() {
this.angularFireMessaging.messages.subscribe((payload: any) => {
console.log('new message received. ', payload);
const NotificationOptions = {
body: payload.notification.body,
data: payload.data,
icon: payload.notification.icon
}
navigator.serviceWorker.getRegistration('/firebase-cloud-messaging-push-scope').then((registration: any) => {
registration.showNotification(payload.notification.title, NotificationOptions);
});
this.currentMessage.next(payload);
});
this.angularFireMessaging.onMessage((res) => {
console.log('@@@@: ', res);
})
}
}

View File

@ -11,4 +11,9 @@ firebase.initializeApp({
measurementId: "G-RQF97ZK7R1"
});
const messaging = firebase.messaging();
const messaging = firebase.messaging();
self.addEventListener('notificationclick', function(event) {
event.notification.close();
event.waitUntil(self.clients.openWindow(event.notification.data.url));
});