logo

sendFcmMessage

The sendFcmMessage method sends a message to Firebase Cloud Messaging using the v1 API. The target can be a condition, a token or a topic.

  • The token can be obtained with the registerToFCM function.
  • The account is a JSON file that can be downloaded from the Firebase console.
import { sendFcmMessage } from '@aracna/fcm';
import GOOGLE_SERVICE_ACCOUNT from './google-service-account.json';

const message = {
  token: 'YOUR_FCM_TOKEN'
};

sendFcmMessage(GOOGLE_SERVICE_ACCOUNT, message)
  .catch(() => {})
  .then((message) => {
    console.log(message);
  });