npm i --save fcm-push-notifications
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);
});
For more information, please refer to the following documentation: