Cloud Messaging API
Firebase Cloud Messaging wrapper for push notifications to mobile devices.
What It Does
The Cloud Messaging API provides a simplified interface for sending push notifications and data messages to mobile devices using Firebase Cloud Messaging (FCM). It handles batch delivery, platform-specific formatting, and failure tracking automatically.
Key Capabilities
- Batch Delivery: Send to multiple devices in one operation
- Rich Notifications: Title, body, images, badge counts
- Custom Data: Arbitrary key-value metadata
- Cross-Platform: Optimized payloads for Android and iOS
- Failure Tracking: Returns only failed tokens for retry logic
- High Priority: Android high-priority notifications
- APNS Integration: iOS-specific features (badge, mutable content)
Main Components
CloudMessagingService
async sendMessage(data: any, ...tokens: string[]): Promise<string[]>
async sendNotification(notification: ICloudNotification, ...tokens: string[]): Promise<string[]>Both methods return arrays of failed tokens for retry handling.
ICloudNotification Interface
{
title: string // Notification title
body: string // Notification message
badgeCount: number // iOS badge count
imageUrl?: string // Optional image
additionalData?: {[key: string]: string} // Custom metadata
}Platform-Specific Features
Android
- High priority notifications
- High-priority image handling
- Data payload support
iOS (APNS)
- Mutable content for rich notifications
- Badge count management
- FCM image URL options
Common Use Cases
- Transactional alerts (order updates, messages)
- Marketing push campaigns
- Real-time notifications (chat, mentions)
- System alerts and warnings
- News and content updates
Roadmap
Multi-Cloud Support
This API currently supports Google Cloud Platform. Future versions will add support for additional cloud providers and container-based deployment options, enabling greater flexibility in infrastructure choices.
What Customers Don’t Have to Build
- Firebase Cloud Messaging integration
- Batch delivery operations
- Platform-specific payload formatting
- Failure tracking and retry logic
- Multi-device messaging
- Android/iOS optimization
- Badge count management
Last updated on