'Not receiving push notifications on desktop browsers

I was using push notifications on my site just fine until recently, they stopped working. I'm using kreait/firebase-php to send the notifications and there are no errors there.

My service worker has this code to handle them

self.addEventListener('push', function(event) {
  //handle background push notifications
  console.log(event);
  const notif = event.data.json();
  console.log(notif);
  const options = {
    body: notif.notification.body,
    icon: notif.notification.icon,
    tag: notif.fcmMessageId,
    data: notif.notification.click_action
  };
  event.waitUntil(self.registration.showNotification(notif.notification.title, options));
});

When I send a test message from Chrome devtools > Applications > Service Worker, the first console.log appears, then there is this error: Uncaught SyntaxError: Unexpected token T in JSON at position 0. I'm not getting notifications on firefox either but I am receiving them on Chrome Android. I'm sending them to all 3 of these devices simultaneously.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source