FIX: Avoid Safari service worker error on back navigation (#12171)

FIX: Avoid Safari service worker error on back navigation (#12171)

diff --git a/app/assets/javascripts/discourse/app/lib/push-notifications.js b/app/assets/javascripts/discourse/app/lib/push-notifications.js
index b9ed09f..7d1012b 100644
--- a/app/assets/javascripts/discourse/app/lib/push-notifications.js
+++ b/app/assets/javascripts/discourse/app/lib/push-notifications.js
@@ -53,7 +53,7 @@ export function isPushNotificationsSupported(mobileView) {
   if (
     !(
       "serviceWorker" in navigator &&
-      ServiceWorkerRegistration &&
+      typeof ServiceWorkerRegistration !== "undefined" &&
       typeof Notification !== "undefined" &&
       "showNotification" in ServiceWorkerRegistration.prototype &&
       "PushManager" in window

GitHub sha: 9063520d

1 Like

This commit appears in #12171 which was approved by CvX. It was merged by pmusaraj.