Answer the question
In order to leave comments, you need to log in
Notifications API or how to track a user's click on "x"?
Actually the question is quite simple, but I can not find the answer to it for quite a long time.
The site has a push notification. It is necessary to put an event listener on a click or action on this push and "understand" that "x" was pressed, that is, the push was closed.
granted, denied, default statuses I get, but they in no way tell me the status of the modal - whether it was closed or not...
For example:
1) The user is logged into the site.
Notification.permission will be default
2) I saw push clicked on the cross push closed
Notification.permission will be default
Actually the question is how to get the state of this push?
And how to determine that the user closed the push with a cross?
Answer the question
In order to leave comments, you need to log in
Here is the solution:
Notification.requestPermission(function(status) {
if(status === 'default') {
console.log('Push closed!');
}
});
maybe this will help or suggest ideas
https://stackoverflow.com/a/40348292
self.addEventListener('notificationclose', function(event) {
// Do something as the result of the notification close
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question