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

OptionTypeDefault or requirement
projectIdstringrequired
clientEmailstringservice account email
privateKeystringPEM 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

Learn more

Next

On this page