/* Handle incoming messages while the app is not in focus
(i.e in the background, hidden behind other tabs, or completely closed).*/
if (messaging) {
messaging.onBackgroundMessage((payload) => {
const { title, body, icon, ...restPayload } = payload.data;
const notificationOptions = {
body,
data: restPayload,
// path to your "fallback" firebase notification logo
icon: icon || './favicon.ico',
};
return self.registration.showNotification(title, notificationOptions);
});
}