Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JSConfAR ticket sold notification
function sendNotification(data){
new Notification("Entrada Vendida!", {icon: "", body: data.availableRegularTickets + "\n"+data.lastBuyerName.substring(0, 30).ucwords()});
function ticketSold(data) {
// Let's check if the user is okay to get some notification
if (Notification.permission === "granted") {
// If it's okay let's create a notification
// Otherwise, we need to ask the user for permission
// Note, Chrome does not implement the permission static property
// So we have to check for NOT 'denied' instead of 'default'
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// Whatever the user answers, we make sure we store the information
if (!('permission' in Notification)) {
Notification.permission = permission;
// If the user is okay, let's create a notification
if (permission === "granted") {
var socket = io.connect('');
socket.on('availability', ticketSold);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment