Open web-dave opened 7 years ago
touch src/ngsw/plugins/clickNotification.js
export function ClickNotification () {
return (worker) => new ClickNotificationImpl(worker);
}
export class ClickNotificationImpl {
setup (ops) {}
constructor (sw) {}
}
...
import { ClickNotification } from './plugins/clickNotification';
bootstrapServiceWorker({
manifestUrl: 'ngsw-manifest.json',
plugins: [
StaticContentCache(),
Dynamic([
new FreshnessStrategy(),
new PerformanceStrategy(),
]),
ExternalContentCache(),
RouteRedirection(),
Push(),
ClickNotification()
],
});
notificationclick(){
self.addEventListener('notificationclick', function (event) {
console.log('notificationclick: ', event);
});
}
notificationclose(){
self.addEventListener('notificationclose', function (event) {
console.log('notificationclose');
});
}
constructor(sw) {
this.notificationclick();
this.notificationclose();
}
npm run build-ngsw
clickNotification.js
code below
ClickNotification
as a plugin in your ServiceWorkernotificationclick
andnotificationclose