Push Notification For Mentions

Objective

  • When an inspector is @ mentioned in the activity feed of an inspection, send a push notification to their mobile device so they see it even when the app is closed or in the background.
  • Keep existing behavior: in-app notifications and email for mentions stay as-is; push is an additional channel for mobile.

Background

  • Today, @ mentions in the activity feed create in-app notifications (stored in the backend and shown in the web app) and can trigger email via sendEmailNotification. There is no push path to mobile devices.
  • Inspectors using the mobile app need to be notified on their device when someone mentions them so they can respond without having to open the app or check email.
  • The activity feed lives on the inspection workorder; notes (and their mentions) are created via the notes API and rendered in ActivityFeed / InspectionActivityFeed.

Scope

  • Backend (attik-backend)
    Mention notifications are created in src/util/notifications/notificationService.ts: createMentionNotifications builds in-DB notifications and calls createNotification, which also triggers sendEmailNotification in src/util/notifications/emailNotificationService.ts. Notes (and thus mentions) are created in src/routes/notes.ts, which calls createMentionNotifications after a note is saved (around lines 206–214). Notifications are stored per the model in src/models/notificationSchema.ts and exposed via src/routes/notifications.ts (list, count, mark read, delete). There is no existing push infrastructure (no FCM, APNs, or Expo Push in this repo). In scope: deciding how to deliver push for mention notifications (e.g. device token storage, who sends push—backend vs separate service—and how it is triggered from the existing createNotification / createMentionNotifications flow). No prescriptive implementation; the developer should align with how the mobile app registers for and receives push.
  • Frontend (attik-frontend)
    The activity feed and mention UI are in src/components/activityFeed/ActivityFeed.tsx, src/app/tools/inspections/[id]/components/InspectionActivityFeed.tsx, and mention parsing in src/util/functions/data/parseContentWithMentions. The dashboard "Recent mentions" experience is in src/components/dashboard/RecentMentions/MentionsList.tsx, which opens /inspections/${notification.inspection._id}?tab=activity-feed. No change is required here for "when" mentions fire; optional: ensure any deep link or URL used in the push payload (e.g. to open the inspection's activity feed) matches this pattern if the mobile app uses it.
  • Mobile (attik-mobile)
    The app lives in the workspace under attik-mobile (app root: attik-mobile/attik-mobile). It is an Expo app (Expo ~54); expo-notifications is not in package.json, so push registration and handling are not yet implemented. The app already supports mention notes in-app: notes that mention the user are fetched in hooks/useInspectionNotes.ts (note API with withMentions: 'true' and inspectorId), displayed in components/inspection/NotesSection.tsx in a "Mentioned" section with unread styling, and the associated in-app notification is marked read via the backend notification/:id/read endpoint when the user views the note. Types for NoteMention and Note.notification are in types/index.ts; mention parsing for display is in lib/parseContentWithMentions.tsx. The inspection detail screen is app/inspection/[id].tsx (with notes in a tab/section); the URL scheme in app.config.js is attikmobile, which can be used for deep links in the push payload (e.g. open /inspection/{inspectionId} or the notes section). In scope: adding push support—register device tokens with the backend or push provider, handle incoming push when the user is @ mentioned, and optionally deep link to the inspection (or inspection notes). Decisions about token registration, payload shape, and deep link path are left to the developer; the existing mention/notification UI and API usage in NotesSection.tsx and useInspectionNotes.ts are the in-app target once the user opens the app from push.

References

  • Backend mention notification flow: attik-backend/src/util/notifications/notificationService.ts (createMentionNotifications, createNotification)
  • Where mentions are triggered: attik-backend/src/routes/notes.ts (note creation and call to createMentionNotifications)
  • Notification model: attik-backend/src/models/notificationSchema.ts
  • Mobile mention/notes UI: attik-mobile/hooks/useInspectionNotes.ts, attik-mobile/components/inspection/NotesSection.tsx, attik-mobile/lib/parseContentWithMentions.tsx; inspection detail: attik-mobile/app/inspection/[id].tsx; app scheme: attik-mobile/app.config.js (scheme attikmobile)
  • Firebase Cloud Messaging (FCM) (Android and cross-platform)
  • Apple Push Notification service (APNs)
  • Expo Push Notifications (Expo app; use with EAS and backend token storage)

Please authenticate to join the conversation.

Upvoters
Status

Completed

Board
🏠

Main App

Date

4 months ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.