Open shaahin18 opened 4 months ago
The example in the demo code is here: https://github.com/majorimi/blazor-components/blob/master/src/Majorsoft.Blazor.Components.TestApps.Common/wwwroot/sw.js
The actions you specify must be handled in the notificationclick
event as described in related documentation:
https://docs.w3cub.com/dom/serviceworkerglobalscope/notificationclick_event
So in the example code you would do various things in JavaScript based on the action clicked:
self.addEventListener('notificationclick', event => {
let action = event.action;
let customData = event.notification.data;
if (action = "action1") {
!!!DoSomeJavaScriptHere!!!
}
let notification = event.notification;
console.log("Notification clicked: " + notification);
});
This is why you are passing the URL to a JavaScript file to the HtmlServiceWorkerNotificationOptions
. That is where the action handlers live.
hi majorimi in your blazor-component notification, i can make notification appearing with 2 actions( copy paste your code!). but when clicking on notification buttons nothing happened. i know i must get that actions(action1,action2) in service worker.but can you explain or reference me to document for understanding how to do things such as go to a page or etc when user clicked on action buttons in notification popup. thanks alot