parent
efb8095e2f
commit
72808c3c7c
@ -30,7 +30,8 @@
|
|||||||
"src/favicon.ico",
|
"src/favicon.ico",
|
||||||
"src/assets",
|
"src/assets",
|
||||||
"src/manifest.webmanifest",
|
"src/manifest.webmanifest",
|
||||||
"src/firebase-messaging-sw.js"
|
"src/firebase-messaging-sw.js",
|
||||||
|
"src/sw-master.js"
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"node_modules/primeng/resources/themes/bootstrap4-light-blue/theme.css",
|
"node_modules/primeng/resources/themes/bootstrap4-light-blue/theme.css",
|
||||||
|
|||||||
@ -69,7 +69,7 @@ import { DownloadAppDirective } from './directives/download-app.directive';
|
|||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
ServiceWorkerModule.register('ngsw-worker.js', {
|
ServiceWorkerModule.register('/sw-master.js', {
|
||||||
enabled: environment.production,
|
enabled: environment.production,
|
||||||
// Register the ServiceWorker as soon as the application is stable
|
// Register the ServiceWorker as soon as the application is stable
|
||||||
// or after 30 seconds (whichever comes first).
|
// or after 30 seconds (whichever comes first).
|
||||||
|
|||||||
@ -89,9 +89,6 @@ export class MessagingService {
|
|||||||
data: payload.data,
|
data: payload.data,
|
||||||
icon: payload.notification.icon
|
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.currentMessage.next(payload);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
11
angular/src/firebase-messaging-sw.js
vendored
11
angular/src/firebase-messaging-sw.js
vendored
@ -1,5 +1,5 @@
|
|||||||
importScripts('https://www.gstatic.com/firebasejs/9.17.1/firebase-app.js');
|
importScripts('https://www.gstatic.com/firebasejs/3.6.9/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-messaging.js');
|
||||||
|
|
||||||
firebase.initializeApp({
|
firebase.initializeApp({
|
||||||
apiKey: "AIzaSyCnKvln5itnrBj62POCPHxshAN_Vmd0zds",
|
apiKey: "AIzaSyCnKvln5itnrBj62POCPHxshAN_Vmd0zds",
|
||||||
@ -11,9 +11,4 @@ firebase.initializeApp({
|
|||||||
measurementId: "G-RQF97ZK7R1"
|
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));
|
|
||||||
});
|
|
||||||
8
angular/src/sw-custom.js
vendored
Normal file
8
angular/src/sw-custom.js
vendored
Normal 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
2
angular/src/sw-master.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
importScripts('./ngsw-worker.js');
|
||||||
|
importScripts('./sw-custom.js');
|
||||||
Loading…
Reference in New Issue
Block a user