fcm-push-notifications
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Installation

npm i --save fcm-push-notifications

Usage

import {
  AndroidMessagePriority,
  FcmPushNotification,
  IFCMResponse,
  IFMCAndroidConfig,
} from 'fcm-push-notifications';

const notification = new FcmPushNotification(
  'my-project-id',
  './credentials/google-services.json'
);

const androidOptions: IFMCAndroidConfig = {
  collapse_key: 'COLLAPSE_KEY',
  priority: AndroidMessagePriority.HIGH,
  data: {
    prop1: 'Prop 1',
    prop2: 'Prop 1',
  },
  notification: {
    title: 'notification title',
    body: 'notification body',
    icon: 'https://banner2.cleanpng.com/20191013/tat/transparent-ui-icon-notification-icon-bell-icon-5da3d1f3d32951.3009239215710172038649.jpg',
    color: '#ff0000',
    tag: 'CUSTOM_TAG',
  },
};

notification
  .send({
    message: {
      token:
        'my-registration-token',
      android: androidOptions,
    },
  })
  .then((response: IFCMResponse) => {
    console.log('response', response);
  });

References

For more information, please refer to the following documentation:

Firebase Cloud Messaging HTTP protocol

Readme

Keywords

Package Sidebar

Install

npm i fcm-push-notifications

Weekly Downloads

3

Version

2.0.0

License

ISC

Unpacked Size

27.4 kB

Total Files

26

Last publish

Collaborators

  • moises.aleman
  • carlos.ibarra.castro