Detect notification pop-up dismissed with cancel button - Javascript - Chrome

Viewed 215

I am trying to implement web based push-notifications on a website. Till so far everything is working. I am troubling with some small bug.

The user flow is as following: User ads favorite -> self made pop-up appears on overlay -> user accepts to get messages -> Chrome shows notification pop-up.

Popup example

The pop-up shows three options Block, allow and cancel(top-right corner X)

  • Block => notification.perimission = 'denied'
  • Allow => notification.permission = 'granted'
  • Cancel => Does nothing just hiding the pop-up

Handling the "allow" and "block" function is logical. But at this moment when a user press on the cancel button the overlay remain on the screen. The user has to press another time on the screen to remove the overlay.

I would like to detect if the cancel button is pressed or the chrome pop-up is hidden.

Does anyone have a solution for this?

1 Answers
Notification.requestPermission().then(res => console.log(res)) 

In the console you will see the message "default" this is the case when the cancel button is pressed.

Related