cmac cmac - 6 months ago 14
Javascript Question

How to check if notifications is already allowed by user in google chrome?

I have a modal that pops up first asking if the user wants to receive special offers, if they click yes, then I pull in the code for push notifications so that they can allow notifications. If they already allowed notifications I don't want the modal to pop up. I am looking for a way to check if notifications has already been allowed by the user, using google chrome.


Check the permission property of the Notification object:

if (Notification.permission !== "granted") {
    // ask for permission