30 lines
1018 B
JavaScript
30 lines
1018 B
JavaScript
|
|
importScripts(
|
|
'https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js'
|
|
)
|
|
importScripts(
|
|
'https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js'
|
|
)
|
|
firebase.initializeApp({"apiKey":"AIzaSyB6PlyAxtiuc3Lr8PM5y2W8E_KxWrXDSkI","authDomain":"barg-336706.firebaseapp.com","projectId":"barg-336706","storageBucket":"barg-336706.appspot.com","messagingSenderId":"889370893165","appId":"1:889370893165:web:198f891c6c49fc13a09864","measurementId":"G-C91HQP1H4V"})
|
|
|
|
// Retrieve an instance of Firebase Messaging so that it can handle background
|
|
// messages.
|
|
const messaging = firebase.messaging()
|
|
|
|
self.addEventListener('push', function (e) {
|
|
console.log('test*******************************')
|
|
data = e.data.json();
|
|
var options = {
|
|
body: data.notification.body,
|
|
icon: data.notification.icon,
|
|
vibrate: [100, 50, 100],
|
|
data: {
|
|
dateOfArrival: Date.now(),
|
|
primaryKey: '2'
|
|
},
|
|
};
|
|
e.waitUntil(
|
|
self.registration.showNotification(data.notification.title, options)
|
|
);
|
|
});
|