правки
This commit is contained in:
gofnnp 2023-03-08 01:36:27 +04:00
parent efb8095e2f
commit 72808c3c7c
6 changed files with 16 additions and 13 deletions

View File

@ -30,7 +30,8 @@
"src/favicon.ico",
"src/assets",
"src/manifest.webmanifest",
"src/firebase-messaging-sw.js"
"src/firebase-messaging-sw.js",
"src/sw-master.js"
],
"styles": [
"node_modules/primeng/resources/themes/bootstrap4-light-blue/theme.css",

View File

@ -69,7 +69,7 @@ import { DownloadAppDirective } from './directives/download-app.directive';
HttpClientModule,
BrowserAnimationsModule,
BrowserModule,
ServiceWorkerModule.register('ngsw-worker.js', {
ServiceWorkerModule.register('/sw-master.js', {
enabled: environment.production,
// Register the ServiceWorker as soon as the application is stable
// or after 30 seconds (whichever comes first).

View File

@ -89,9 +89,6 @@ export class MessagingService {
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);
});
}

View File

@ -1,5 +1,5 @@
importScripts('https://www.gstatic.com/firebasejs/9.17.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/9.17.1/firebase-messaging.js');
importScripts('https://www.gstatic.com/firebasejs/3.6.9/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.6.9/firebase-messaging.js');
firebase.initializeApp({
apiKey: "AIzaSyCnKvln5itnrBj62POCPHxshAN_Vmd0zds",
@ -11,9 +11,4 @@ firebase.initializeApp({
measurementId: "G-RQF97ZK7R1"
});
const messaging = firebase.messaging();
self.addEventListener('notificationclick', function(event) {
event.notification.close();
event.waitUntil(self.clients.openWindow(event.notification.data.url));
});
const messaging = firebase.messaging();

8
angular/src/sw-custom.js vendored Normal file
View File

@ -0,0 +1,8 @@
(function () {
"use strict";
self.addEventListener("notificationclick", (event) => {
event.notification.close();
console.log("notification details: ", event.notification);
});
})();

2
angular/src/sw-master.js vendored Normal file
View File

@ -0,0 +1,2 @@
importScripts('./ngsw-worker.js');
importScripts('./sw-custom.js');