fcm-sender
v1.0.2
Published
firebase cloud message nodejs package
Downloads
1
Maintainers
Readme
FCM Sender
FCM Sender is node js package to send notification to mobile app ( android and ios devices ) by node js
Installation
Use the package manager npm to install FCM Sender.
npm install --save fcm-sender
Usage
const FCMSender = require('fcm-sender');
##Intialize
//put your firebase app key
const intialFCM = new FCMSender('APA91bExJnQUo_83d24xB2ZsfYRX....');
##Set Data And Send
//put your option in second step
const dataSendToSepicficMobil = new FCMSender.sendForMobileToken(intialFCM,{
receivers : 'APNAPA91bE9kJIXCHe62jKDf....',
notification : {
title : 'notification title',
body : 'notification message',
image: 'url image',
},
data : {
key : 'data'
}
})
//send notification fire
dataSendToSepicficMobil.send();
##Options
Topic send notification to all device by specific topic you can use sendForMobileTopic class
const dataSendToSepicficMobil = new FCMSender.sendForMobileTopic(intialFCM,{
topic : 'your topic hear', //topic that can recived notification
notification : {
title : 'notification title',
body : 'notification message',
image: 'url image',
},
data : {
key : 'data'
}
})
in android handle
FirebaseMessaging.getInstance().subscribeToTopic("your-topic-hear")
in IOS handle
[[FIRMessaging messaging] subscribeToTopic:@"your-topic-hear"
completion:^(NSError * _Nullable error) {
NSLog(@"Subscribed to your topic");
}];
send to one device or group
//code send to mobile
const dataSendToSepicficMobil = new FCMSender.sendForMobileToken(intialFCM,{
receivers : 'APNAPA91bE9kJIXCHe62jKDf....', // the reciver mobile registeration token
notification : {
title : 'notification title',
body : 'notification message',
image: 'url image',
},
data : {
key : 'data'
}
})
{ receivers : 'APNAPSDA91bE9kJIXCHe62jKDf....'} //one decive
//Or
{ receivers : ['AOPPNAPASD91bE9kJIXCHe62jKDf....','APIJK1bE9kJIMKXCHe62jKDf.....'] //for more divices or group }
##Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.