Repository navigation
Closed
Description
Summary
Add Firebase Cloud Messaging (FCM) to deliver push notifications to Android and web clients from the Go backend.
Scope
Backend (Go)
- Add
firebase.google.com/go/v4Admin SDK (shared with the Firebase Auth integration from feat: add Firebase Authentication across all app layers #15) - Add a notification service in
usecase/with aSendNotificationinterface - Implement in
infrastructure/using the FCM HTTP v1 API via the Admin SDK - Expose an internal helper that other use cases can call to trigger notifications (e.g. after a background job completes via QStash feat: integrate Asynq + Redis Streams for background jobs and event-driven messaging #18)
- Store
FIREBASE_SERVICE_ACCOUNT_JSON(or path to the key file) in env — document inbackend/.env.example
Web (Next.js)
- Add
firebaseJS SDK (shared with Firebase Auth feat: add Firebase Authentication across all app layers #15) - Request notification permission and obtain an FCM registration token on the client
- Register a service worker (
public/firebase-messaging-sw.js) to handle background messages - Send the registration token to the backend so it can be stored per-user
- Handle foreground messages via
onMessage()
Mobile (Android / Jetpack Compose)
- Add
com.google.firebase:firebase-messagingvia version catalog - Extend
FirebaseMessagingServiceto handle foreground and background messages - On token refresh, send the new FCM token to the backend
- Display notifications using
NotificationCompatfor background delivery; handle foreground in-app
Backend storage
- Migration: add
fcm_tokenstable (user_id,token,platform,created_at) so the backend can fan-out to all of a user's devices
Acceptance criteria
- Backend can send a notification to a specific FCM token via the Admin SDK
- Web client receives foreground and background push notifications
- Android client receives foreground and background push notifications
- FCM tokens are stored per-user and cleaned up on logout (ties into feat: add Firebase Authentication across all app layers #15)
-
FIREBASE_SERVICE_ACCOUNT_JSONadded tobackend/.env.examplewith a placeholder and comment - Migration created for
fcm_tokenstable - Tests written for the notification use case (unit) and token storage (integration)
- Docs added to
backend/docs/fcm.md,web/docs/fcm.md, andmobile/docs/fcm.md
Dependencies
- feat: add Firebase Authentication across all app layers #15 Firebase Auth (shares Firebase project and Admin SDK setup)
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat(fcm): integrate Firebase Cloud Messaging for push notifications