mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
message
This commit is contained in:
@@ -1,11 +1,3 @@
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('./firebase-messaging-sw.js')
|
||||
.then(function(registration) {
|
||||
}).catch(function(err) {
|
||||
});
|
||||
}
|
||||
// Scripts for firebase and firebase messaging
|
||||
|
||||
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
|
||||
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');
|
||||
|
||||
@@ -36,4 +28,33 @@ messaging.onBackgroundMessage(function(payload) {
|
||||
|
||||
self.registration.showNotification(notificationTitle,
|
||||
notificationOptions);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
self.addEventListener('install', function(event) {
|
||||
self.skipWaiting();
|
||||
console.log('Installed', event);
|
||||
});
|
||||
|
||||
self.addEventListener('activate', function(event) {
|
||||
console.log('Activated', event);
|
||||
});
|
||||
|
||||
self.addEventListener('push', function(event) {
|
||||
|
||||
var uid = "EXISTS_IN_CORE.JS";
|
||||
var token = "ALSO_EXISTS_IN_CORE.JS";
|
||||
|
||||
console.log("Push recieved - we need to know the uid and token here, from core.js");
|
||||
});
|
||||
|
||||
self.addEventListener('message', function(event){
|
||||
var data = JSON.parse(event.data);
|
||||
|
||||
console.log("SW Received Message:");
|
||||
console.log(data);
|
||||
|
||||
self.userID = data.uid;
|
||||
self.userToken = data.token;
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user