Transports
FCM
Send mobile push through Firebase Cloud Messaging HTTP v1.
Send device-token push through Firebase Cloud Messaging HTTP v1 for native Android and iOS clients. Use Web Push when you have a browser Push API subscription instead.
The one rule
Pass
token in push options — not a Web Push subscription.Quick start
import { createPushSender } from "sently/push";
import { FcmTransport } from "sently/transports/fcm";
const push = createPushSender({
transport: new FcmTransport({
projectId: process.env.FCM_PROJECT_ID!,
clientEmail: process.env.FCM_CLIENT_EMAIL!,
privateKey: process.env.FCM_PRIVATE_KEY!,
}),
});const result = await push.send({
token: deviceRegistrationToken,
title: "Hello",
body: "World",
});
console.log(result.messageId, result.status);Configuration
| Option | Type | Default or requirement |
|---|---|---|
projectId | string | required |
clientEmail | string | service account email |
privateKey | string | PEM private key (env / secrets only) |
getAccessToken | () => Promise<string> | optional override for tests |
Literal \n sequences in privateKey env strings are normalized to newlines.
The transport mints a short-lived OAuth2 token with scope firebase.messaging — no Google SDK.
Troubleshooting
No. FcmTransport requires token. Use WebPushTransport for VAPID subscriptions.
Download a Firebase / GCP service account JSON and pass project_id, client_email, and private_key from that file via environment variables.