From 61f2132abdb93c38bebf83f54450a09b0ec47f23 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 7 Sep 2023 12:17:31 +0800 Subject: [PATCH] Fix getNotifications is not a function --- src/pages/notifications.jsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pages/notifications.jsx b/src/pages/notifications.jsx index 7e3edfbb..d60e7ef5 100644 --- a/src/pages/notifications.jsx +++ b/src/pages/notifications.jsx @@ -206,15 +206,17 @@ function Notifications({ columnMode }) { useEffect(() => { if (uiState === 'default') { (async () => { - const registration = await getRegistration(); - if (registration) { - const notifications = await registration.getNotifications(); - console.log('🔔 Push notifications', notifications); - // Close all notifications? - // notifications.forEach((notification) => { - // notification.close(); - // }); - } + try { + const registration = await getRegistration(); + if (registration?.getNotifications) { + const notifications = await registration.getNotifications(); + console.log('🔔 Push notifications', notifications); + // Close all notifications? + // notifications.forEach((notification) => { + // notification.close(); + // }); + } + } catch (e) {} })(); } }, [uiState]);