Skip to content

feat: integrate Firebase Cloud Messaging for push notifications #19

@GRACENOBLE

Description

@GRACENOBLE

Summary

Add Firebase Cloud Messaging (FCM) to deliver push notifications to Android and web clients from the Go backend.

Scope

Backend (Go)

Web (Next.js)

  • Add firebase JS 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-messaging via version catalog
  • Extend FirebaseMessagingService to handle foreground and background messages
  • On token refresh, send the new FCM token to the backend
  • Display notifications using NotificationCompat for background delivery; handle foreground in-app

Backend storage

  • Migration: add fcm_tokens table (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_JSON added to backend/.env.example with a placeholder and comment
  • Migration created for fcm_tokens table
  • Tests written for the notification use case (unit) and token storage (integration)
  • Docs added to backend/docs/fcm.md, web/docs/fcm.md, and mobile/docs/fcm.md

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions