Warning: on February 2, 2017, the Firebase Team released the admin.messaging() service to their node.js admin module. This new service makes this module kind of deprecated
fcm-node
A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM). Supports both android and iOS, including topic messages, and parallel calls.
Aditionally it also keeps the callback behavior for the new firebase messaging service.
Installation
Via npm:
$ npm install fcm-node
Usage
There are 2 ways to use this lib:
The classic one
- Generate a Server Key on your app's firebase console and pass it to the FCM constructor
- Create a message object and call the send() function
var FCM = require('fcm-node');
var serverKey = 'YOURSERVERKEYHERE'; //put your server key here
var fcm = new FCM(serverKey);
var message = { //this may vary according to the message type (single recipient, multicast, topic, et cetera)
to: 'registration_token',
collapse_key: 'your_collapse_key',
notification: {
title: 'Title of your push notification',
body: 'Body of your push notification'
},
data: { //you can send only notification or only data(or include both)
my_key: 'my value',
my_another_key: 'my another value'
}
};
'node.js & js' 카테고리의 다른 글
( 스크랩 ) Socket.IO APIs (0) | 2019.03.04 |
---|---|
node.js 에서 Json 객체 받아서 사용하기 (0) | 2018.12.31 |
윈도우 node.js 설치 및 실행 (0) | 2018.12.28 |
socket.io 에서 on 이 여러번 실행되는 이슈 (0) | 2018.06.21 |
node js에서 fcm 푸시 메세지 보내기 (0) | 2018.06.15 |