Fcmlly - Integrate with Google cloud messaging easily
Best way to send your push notifications.
I accept any contributes with open arms \./
Installation
npm i fcmlly
Usage
const Fcmlly = require('fcmlly');
const fcmlly = new Fcmlly('YOUR_APIKEY_HERE'); // Get this key from Firebase console > Settings (page) > Cloud Messaging (tab) > Project credentials (section) > Server Key
Samples
const res = await fcmlly.pushToUser('user fcm token', 'youe title text', 'your body text');
console.log(res);
or
fcmlly.pushToUser('user fcm token', 'youe title text', 'your body text').then((res) => { console.log(res) }).catch((err) => { console.error(err) });
// sample console output:
// {
// multicast_id: 76468637435051*****,
// success: 1,
// failure: 0,
// canonical_ids: 0,
// results: [ { message_id: '0:1603183795340265%a5e3d8a7a5e*****' } ]
// }
Methods
-
Push to a user
.push('userId', 'title', 'body')
-
Push to all users in a topic
.pushToTopic('topic name', 'title', 'body')