Skip to content

Comments

Add Android push notifications via Firebase Cloud Messaging#3

Merged
johnnyluo merged 2 commits intomainfrom
add-android-firebase-notification
Feb 24, 2026
Merged

Add Android push notifications via Firebase Cloud Messaging#3
johnnyluo merged 2 commits intomainfrom
add-android-firebase-notification

Conversation

@johnnyluo
Copy link
Contributor

Summary

  • Implements processAndroidNotification() using the official Firebase Admin Go SDK (firebase.google.com/go/v4)
  • The *messaging.Client is initialised once at worker startup from a service account credentials file and reused for every notification (no per-request re-initialisation)
  • If firebase-credentials is empty/unset the worker starts normally and android notifications are skipped with a warning log (graceful degradation)

Changes

File Change
service/notification.go Add firebaseMessaging field, update constructor, implement processAndroidNotification()
config/config.go Add FirebaseCredentials mapped to firebase-credentials config key
cmd/worker/main.go Pass cfg.FirebaseCredentials to service constructor
go.mod / go.sum Add firebase.google.com/go/v4 dependency

Notification payload

Mirrors the existing APNs notification:

  • Title: "Vultisig Keysign request"
  • Body: "Vault: <vault_name>"
  • Data: {"message": "<qr_code_data>"}

Stale tokens (IsUnregistered FCM error) trigger automatic device removal from the database, matching the existing APNs behaviour.

Test plan

  • Place a Firebase service account JSON at cmd/worker/firebase-service-account.json and set "firebase-credentials" in config.json
  • Register an Android device via POST /register with device_type: "android"
  • Trigger POST /notify with the matching vault_id and confirm the device receives the notification
  • Verify stale-token cleanup: use an invalid FCM token, trigger a notification, confirm the device row is removed from the DB
  • Run go test ./...

🤖 Generated with Claude Code

johnnyluo and others added 2 commits February 24, 2026 16:15
Implement processAndroidNotification() using the Firebase Admin Go SDK
(firebase.google.com/go/v4). The Firebase messaging client is
initialized once at worker startup from a service account credentials
file and reused for every notification. If no credentials file is
configured the service degrades gracefully with a warning log.

- Notification payload mirrors APNs: title "Vultisig Keysign request",
  body "Vault: <name>", and QR code data passed as a data field
- Stale/unregistered FCM tokens (IsUnregistered error) trigger
  automatic device cleanup from the database, matching APNs behaviour
- Add FirebaseCredentials field to Config (firebase-credentials key)
- Update NewNotificationService constructor with credentials parameter

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Combines Android Firebase Cloud Messaging (this branch) with VAPID
web push notifications from the merged branch. Both features are
preserved: Firebase for Android devices, VAPID for web browsers.

- NotificationService struct now holds both firebaseMessaging client
  and VAPID key fields
- Constructor accepts firebaseCredentials + vapidPublicKey/PrivateKey/Subscriber
- Config struct includes both firebase-credentials and vapid-* keys
- go.mod/go.sum regenerated cleanly via go mod tidy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@johnnyluo johnnyluo merged commit 9585be0 into main Feb 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant