2019-10-08 09:12:47 +00:00
|
|
|
importScripts('https://www.gstatic.com/firebasejs/7.1.0/firebase-app.js');
|
|
|
|
importScripts('https://www.gstatic.com/firebasejs/7.1.0/firebase-messaging.js');
|
|
|
|
|
2019-08-23 11:39:42 +00:00
|
|
|
/**
|
|
|
|
* Cache version, change name to force reload
|
|
|
|
*/
|
|
|
|
var CACHE_VERSION = 'v1';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stuff to put in the cache at install
|
|
|
|
*/
|
|
|
|
var CACHE_FILES = [
|
|
|
|
'templates/automatio.phtml',
|
|
|
|
'templates/dashboard.phtml',
|
|
|
|
'templates/home.phtml',
|
|
|
|
'templates/login.phtml',
|
|
|
|
'templates/scene.phtml',
|
|
|
|
'templates/setting.phtml',
|
|
|
|
'views/Automation.phtml',
|
|
|
|
'views/Dashboard.phtml',
|
|
|
|
'views/Home.phtml',
|
|
|
|
'views/Login.phtml',
|
|
|
|
'views/Scene.phtml',
|
|
|
|
'views/Setting.phtml',
|
|
|
|
'assets/logo.svg'
|
|
|
|
];
|
|
|
|
|
|
|
|
|
2019-10-08 14:49:08 +00:00
|
|
|
self.addEventListener('install', function(event) {
|
|
|
|
console.info('Installed');
|
|
|
|
});
|
2019-08-23 11:39:42 +00:00
|
|
|
|
|
|
|
self.addEventListener('push', function(event) {
|
|
|
|
console.log('Received a push message', event);
|
2019-10-08 14:49:08 +00:00
|
|
|
if (event && event.data) {
|
|
|
|
var data = event.data.json();
|
|
|
|
data = JSON.parse(data.data.notification);
|
|
|
|
console.log(data);
|
|
|
|
event.waitUntil(self.registration.showNotification(data.title, {
|
|
|
|
body: data.body,
|
|
|
|
icon: data.icon || null
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('sync', function(event) {
|
|
|
|
console.info('Event: Sync');
|
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('fetch', function (event) {
|
2019-08-23 11:39:42 +00:00
|
|
|
|
2019-10-08 14:49:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener("online", function (event) {
|
2019-08-23 11:39:42 +00:00
|
|
|
|
2019-10-08 14:49:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener("offline", function (event) {
|
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('notificationclick', function(e) {
|
2019-08-23 11:39:42 +00:00
|
|
|
|
2019-10-08 14:49:08 +00:00
|
|
|
});
|
|
|
|
|