JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q29678F
  • License MIT

FCM (send-message) implementation based on REST API, supports proxy

Package Exports

  • fcm-rest
  • fcm-rest/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fcm-rest) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

FCM-REST

npm npm license npm downloads

FCM implementation based on REST API, supports proxy. No dependencies on firebase framework.

Implements send-message HTTP APIs v1 and legacy

Legacy API https://firebase.google.com/docs/cloud-messaging/send-message#send_using_the_fcm_legacy_http_api

V1 API https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages

Installation

npm install fcm-rest

Usage

import fcm from 'fcm-rest'
//const fcm = require('fcm-rest')

// recipient
const clientToken = 'ZkVNZ...'
// Use legacy FCM API
const serverKey = 'AAAA...'
await fcm.sendMessageLegacy(serverKey, clientToken, {
  notification: { title: 'Hi there' }
})
// Use v1 FCM API
const gcpServiceAccount = {
  client_email: '***',
  project_id  : '***',
  private_key : '***',
  ...
}
await fcm.sendMessageV1(gcpServiceAccount, clientToken, {
  notification: { title: 'Hi there' }
})
// Send v1 topic
await fcm.sendMessageV1(gcpServiceAccount, undefined, {
  notification: { title: 'Hi there' },
  topic: 'topic-name'
})