I have try to use FCM for Web Push Notification. I success receive a message when the web app tab is on focus.
But when I close the tab, it suppose to be call the service worker ( which is firebase-messaging-sw.js in FCM sample ). But it didnt call the setBackgroundMessageHandler at all.
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload) {
console.log('[firebase-messaging-sw.js] Received background message ', payload);
const notificationTitle = 'Background Message Title';
const notificationOptions = {
body: 'Background Message body.',
icon: 'firebase-logo.png'
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
Aucun commentaire:
Enregistrer un commentaire