From e3aa5c5c26c732f6ecee7ec91de977a057c78f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Juvenal?= Date: Wed, 5 Feb 2025 20:00:12 -0300 Subject: [PATCH] Fix NotificationsProvider for web --- contexts/NotificationsContext.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contexts/NotificationsContext.tsx b/contexts/NotificationsContext.tsx index 3672076..8cb0360 100644 --- a/contexts/NotificationsContext.tsx +++ b/contexts/NotificationsContext.tsx @@ -28,7 +28,7 @@ const NotificationsContext = createContext({ async function getPushToken() { let token; - if (!Device.isDevice) { + if (!Device.isDevice || Platform.OS === "web") { return; } @@ -99,6 +99,8 @@ export function NotificationsProvider({ children }: { children: React.ReactNode const medplum = useMedplum(); const setUpPushNotifications = useCallback(async () => { + if (Platform.OS === "web") return false; + // Check and request notification permissions const { status: existingStatus } = await Notifications.getPermissionsAsync(); let finalStatus = existingStatus; @@ -125,6 +127,8 @@ export function NotificationsProvider({ children }: { children: React.ReactNode // Effect to handle notifications when app is terminated useEffect(() => { + if (Platform.OS === "web") return; + const getInitialNotification = async () => { const lastNotificationResponse = await Notifications.getLastNotificationResponseAsync(); if (lastNotificationResponse) {