Commit f99bc00ec0c9d051bec1c3d12de33edb5bbc50f2

Authored by Rohan Rangray
1 parent 5498e58201

Removed the '/' at the end of /app/study

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

service-worker.js View file @ f99bc00
'use strict'; 1 1 'use strict';
2 2
function showNotification(title, body, icon, data) { 3 3 function showNotification(title, body, icon, data) {
var notificationOptions = { 4 4 var notificationOptions = {
body: body, 5 5 body: body,
icon: icon ? icon : '/flashy.ico', 6 6 icon: icon ? icon : '/flashy.ico',
tag: 'simple-push-demo-notification', 7 7 tag: 'simple-push-demo-notification',
data: data 8 8 data: data
}; 9 9 };
if (self.registration.showNotification) { 10 10 if (self.registration.showNotification) {
self.registration.showNotification(title, notificationOptions); 11 11 self.registration.showNotification(title, notificationOptions);
return; 12 12 return;
} else { 13 13 } else {
new Notification(title, notificationOptions); 14 14 new Notification(title, notificationOptions);
} 15 15 }
} 16 16 }
17 17
self.addEventListener('push', function(event) { 18 18 self.addEventListener('push', function(event) {
console.log('Received a push message', event); 19 19 console.log('Received a push message', event);
20 20
// Since this is no payload data with the first version 21 21 // Since this is no payload data with the first version
// of Push notifications, here we'll grab some data from 22 22 // of Push notifications, here we'll grab some data from
// an API and use it to populate a notification 23 23 // an API and use it to populate a notification
var title = 'You have cards waiting to be reviewed!'; 24 24 var title = 'You have cards waiting to be reviewed!';
var message = 'check yo cards m8'; 25 25 var message = 'check yo cards m8';
var icon = '/flashy.ico'; 26 26 var icon = '/flashy.ico';
var notificationTag = 'simple-push-demo-notification'; 27 27 var notificationTag = 'simple-push-demo-notification';
28 28
// Add this to the data of the notification 29 29 // Add this to the data of the notification
var urlToOpen = '/api/subscribe/'; 30 30 var urlToOpen = '/api/subscribe/';
31 31
var notificationFilter = { 32 32 var notificationFilter = {
tag: 'simple-push-demo-notification' 33 33 tag: 'simple-push-demo-notification'
}; 34 34 };
var notificationData = { 35 35 var notificationData = {
url: urlToOpen 36 36 url: urlToOpen
}; 37 37 };
return showNotification(title, message, icon, notificationData); 38 38 return showNotification(title, message, icon, notificationData);
}); 39 39 });
40 40