Skip to content

Commit

Permalink
Fix NotificationsProvider for web
Browse files Browse the repository at this point in the history
  • Loading branch information
fjsj committed Feb 5, 2025
1 parent c9357aa commit e3aa5c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion contexts/NotificationsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const NotificationsContext = createContext<NotificationsContextType>({
async function getPushToken() {
let token;

if (!Device.isDevice) {
if (!Device.isDevice || Platform.OS === "web") {
return;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit e3aa5c5

Please sign in to comment.