mercredi 27 novembre 2019

Firebase Web Push Notification stops firing on background

I have a scenario where the push notification does not fire on the background for some reason . this happens intermittently and starts working a while later ! I can see the notification received on the Push Messaging console on chrome. Has anyone faced this issue ?

Here is my notification handle on my service worker


importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js');

var firebaseConfig = {
    ...
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);

const messaging = firebase.messaging();


messaging.setBackgroundMessageHandler(function (payload) {
    console.log('[firebase-messaging-sw.js] Received background message ', payload);
    // Customize notification here
    const notificationTitle = 'Background Message Title';
    const notificationOptions = {
        body: 'Background Message body.',
        icon: '/Assets/Mystays/images/mystays-logo.png',
        image: '/Assets/Mystays/images/mystays-logo512.png',
        badge: '/Assets/Mystays/images/mystays-logo256.png'
    };


    return self.registration.showNotification(notificationTitle,notificationOptions);
}); 

Any sort of help is appreciated




Aucun commentaire:

Enregistrer un commentaire