FCM Integration
Component Detail
Infrastructure
medium complexity
backend
0
Dependencies
1
Dependents
0
Entities
0
Integrations
Description
Infrastructure wrapper around the Firebase Cloud Messaging HTTP v1 API for the Next.js backend. Manages OAuth2 service account authentication, request construction, error classification for token invalidation, and exponential backoff retry for transient delivery failures.
fcm-integration
Responsibilities
- Authenticate with the FCM HTTP v1 API using Google service account credentials and short-lived OAuth2 tokens
- Construct and transmit single and multicast FCM message payloads with notification and data fields
- Classify FCM error responses to distinguish token invalidation errors from transient network failures
- Implement exponential backoff retry logic for transient FCM delivery failures
Interfaces
sendMessage(deviceToken, notification, data)
sendMulticast(deviceTokens, notification, data)
getAccessToken()
isTokenInvalidError(fcmError)