Firebase Cloud Messaging (FCM)
Integrate Firebase Cloud Messaging (FCM) with Enbbox for Android and web push notifications. Setup guide with service account credentials.
Overview
Firebase Cloud Messaging (FCM) is Google's cross-platform push notification service for Android, iOS, and web applications.
[!IMPORTANT] FCM requires a Firebase project and a Service Account JSON key file. The legacy server key is deprecated — Enbbox uses the FCM HTTP v1 API with service account credentials.
Prerequisites
- A Google Firebase account
- A Firebase project with your app registered
- Your app must integrate the Firebase SDK to receive push notifications
Step 1: Create a Firebase Project
- Go to console.firebase.google.com
- Click Add project and enter a project name
- Follow the setup wizard to create the project
- Add your app platform (Android, iOS, or Web)
Step 2: Generate a Service Account Key
- In the Firebase Console, click the gear icon → Project Settings
- Navigate to the Service accounts tab
- Click Generate new private key
- Confirm by clicking Generate key — a JSON file will be downloaded
{
"type": "service_account",
"project_id": "my-project-123",
"private_key_id": "abc123...",
"private_key": "-----BEGIN PRIVATE KEY-----\n...",
"client_email": "[email protected]",
...
}[!CAUTION] This JSON file contains your private key. Store it securely and never commit it to version control.
Step 3: Connect to Enbbox
- Navigate to Integrations in the Enbbox dashboard
- Click Add Provider → select Push → FCM
- Paste the entire Service Account JSON content into the credentials field
- Click Test Connection to verify
- Activate the integration
Step 4: Register Device Tokens
In your mobile/web app, retrieve the FCM device token and store it in the subscriber's credentials:
// Client-side: get the FCM token
import { getToken } from "firebase/messaging";
const token = await getToken(messaging, { vapidKey: "your-vapid-key" });
// Server-side: store it in Enbbox
import { SubscriberCredentialsApi, Configuration } from "@enbbox/api";
const config = new Configuration({ accessToken: "your-api-key" });
const credentialsApi = new SubscriberCredentialsApi(config);
await credentialsApi.setCredentials("subscriber-123", "fcm", {
credentials: { device_tokens: [token] },
});Step 5: Send a Test Notification
import { EventsApi, Configuration } from "@enbbox/api";
const config = new Configuration({ accessToken: "your-api-key" });
const eventsApi = new EventsApi(config);
await eventsApi.triggerEvent({
name: "order-update",
to: { subscriberId: "subscriber-123" },
payload: {
title: "Order Shipped",
body: "Your order #1234 has been shipped!",
},
});Advanced Configuration
Data Payloads
Send custom data to your app alongside the notification:
overrides: {
fcm: {
data: {
orderId: '1234',
screen: 'order-detail',
},
},
}Platform-Specific Options
overrides: {
fcm: {
android: {
priority: 'high',
notification: { sound: 'custom_sound' },
},
webpush: {
notification: { icon: '/icon.png' },
},
},
}Troubleshooting
| Issue | Solution |
|---|---|
| Invalid service account | Ensure you're using the full JSON (not just the key) |
| Token not registered | The device token may be stale — refresh it on app start |
| Notification not received | Check Firebase Console → Cloud Messaging for delivery reports |
| Permission denied | Ensure the service account has the cloudmessaging.messages.create permission |
Push Providers
Enbbox push notification integrations overview. Connect Firebase Cloud Messaging (FCM), Apple Push Notification service (APNs), Expo, OneSignal, and Pushpad.
Apple Push Notification Service (APNs)
Integrate Apple Push Notification service (APNs) with Enbbox. Setup guide with p8 key, team ID, and bundle ID configuration for iOS push notifications.