2.0.0 • Published 4 months ago

fcm-push-notifications v2.0.0

Weekly downloads
8
License
ISC
Repository
-
Last release
4 months ago

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

2.0.0

4 months ago

1.0.1

4 years ago

1.0.0

4 years ago