Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check notification permissopn allow or not

function handlePermission() {
            return navigator.permissions
                    .query({name:'notifications'})
                    .then(permissionQuery)
                    // .catch(permissionError);
        }
        
        function permissionQuery(result) {
            console.debug({result});
            var newPrompt;
        
            if (result.state == 'granted') {
                // console.log('granted');
        
            } else if (result.state == 'prompt') {
                newPrompt = Notification.requestPermission();
                swal("Please Allow Notification..","", "error");
        
            } else if (result.state == 'denied') {
                swal("Please Allow Notification..","", "error");
            }
        
            result.onchange = () => console.debug({updatedPermission: result});
        
            return newPrompt || result;
        }
        
        
        handlePermission();
Comment

PREVIOUS NEXT
Code Example
Javascript :: reactjs moment to string 
Javascript :: show json preformatted 
Javascript :: filter text js 
Javascript :: find numeric Unicode value of the character with charCodeAt() method 
Javascript :: function Tom(a, b) { return a + b; } 
Javascript :: Access models in ExpressJS 
Javascript :: mongo db backup node js daily 
Javascript :: how to choose a weighted random array element in javascript 
Javascript :: express-js 
Javascript :: this javascript 
Javascript :: javascript static methods 
Javascript :: access the prototype of an object javascript 
Javascript :: javascript case insensitive regex 
Javascript :: how to assign an rest operator in javascript 
Javascript :: reactnative timepicker 
Javascript :: how to initialize an array in javascript 
Javascript :: how to turn a string into an array javascript 
Javascript :: pass infinite argument in function 
Javascript :: get array from string javascript 
Javascript :: javascript make do while loop 
Javascript :: css defer async 
Javascript :: javascript exeit from loop 
Javascript :: react native loop in render 
Javascript :: passing data in route react 
Javascript :: how to write unit test cases in react js 
Javascript :: buffer image 
Javascript :: min in array 
Javascript :: onClick={ (window.open react js 
Javascript :: javascript get image data from clipboard 
Javascript :: use length to resize an array 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =