Al hacer clic en la parte de acción de las notificaciones push de @ angular / service-worker
He estado tratando de redirigir a los usuarios a la parte de "acción" de Webpush que viene del backend (PHP).
return (new WebPushMessage)
->title('Title')
->icon('icon.png')
->body('Body Msg')
->action('Open Notification', 'open_notification')
->data(['id' => $notification->id,'url'=>'http://somewhere']);
Los trabajadores de servicios predeterminados usan:
self.addEventListener('notificationclick', function(event) {
console.log('On notification click: ', event.notification.tag);
event.notification.close();
// This looks to see if the current is already open and
// focuses if it is
event.waitUntil(clients.matchAll({
type: "window"
}).then(function(clientList) {
for (var i = 0; i < clientList.length; i++) {
var client = clientList[i];
if (client.url == '/' && 'focus' in client)
return client.focus();
}
if (clients.openWindow)
return clients.openWindow('/');
}));
});
Dehttps://developer.mozilla.org/en-US/docs/Web/Events/notificationclick
Angular 5 usos
import {SwPush, SwUpdate} from '@angular/service-worker';
Mi pregunta es cómo interpretar esto en el front-end (Angular 5) usando @ angular / service-worker