JSFiddle - React, Tailwind, and code Playground
by oroce
HTML
<button>show notification</button>
JavaScript
var showNotification = function( text, title, opts ){
console.log( "hasPermission",window.webkitNotifications.checkPermission() === 0 );
if( window.webkitNotifications.checkPermission() == 0 ){
//we got notification
if( typeof opts === "object" && opts.html ){
window.webkitNotifications.createHTMLNotification("http://index.hu").show();;
}
else{
window.webkitNotifications.createNotification( "", title, text ).show();
}
}
else{
console.log( "else" )
var args = Array.prototype.slice.call( arguments, 0 ),
cb = function(){
showNotification.apply( this, args );
};
window.webkitNotifications.requestPermission( cb );
}
};
$( "button" ).click(function(){
showNotification( "alma","almakontent" );
});