Use Javascript to block page access when Web Browser Push Notification not granted


You want to allow only web push notification subscribers to access a particular page.

If push notification is not granted, the visitor will be alerted and redirected to another page.


Create push-test.js with following code

if (Notification.permission !== "granted") {
    alert("Please allow web notification to get your discount coupon code!");

Add the following code to the page you want to protect

<script src=""></script>

Leave a Reply

Your email address will not be published. Required fields are marked *