So far all I have been able achieve is asking the user for permission to send them notifications & if they accept all that happens is that everytime they open the app they get a greetings notification, achieving that was not complicated because it was straight forward, I placed the code in my main.js script & it runs everytime the service worker gets registered.
CODE:
Notification.requestPermission(result => {
if (result === 'granted') {
showNotification('Welcome to My App™', 'Everything Services™')
}
});
function showNotification(title, message) {
if ('Notification' in window) {
navigator.serviceWorker.ready.then(registration => {
registration.showNotification(title, {
body: message,
tag: 'my-app',
icon:'/init/static/images/icon_192x192.png',
badge:'/init/static/images/icon_128x128.png',
vibrate: [200, 100, 200, 100, 200, 100]
});
});
}
}