class FcmProvider
implements PushTransport
Since 0.1.0

FcmProvider implements PushTransport via the FCM HTTP v1 API.

Authenticates with a short-lived OAuth2 bearer token minted from a service account (see FcmTokenSource), replacing the legacy serverKey API that Google decommissioned in 2024.

Examples

Example 1

const provider = new FcmProvider({
  projectId: 'my-firebase-project',
  clientEmail: 'fcm@my-project.iam.gserviceaccount.com',
  privateKey: config.get('FCM_PRIVATE_KEY'),
  runtime,
});
await provider.send({ to: deviceToken, title: 'Hello', body: 'World' });

Constructors

FcmProvider(options: FcmProviderOptions)

Creates an FcmProvider.

Parameters

Provider configuration

Methods

Since 0.1.0
send(message: PushMessage): Promise<void>

Sends a push notification via the FCM HTTP v1 endpoint.

Usage

import { FcmProvider } from "notification-plugin/src/index.ts";