
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
push-receiver
Advanced tools
A module to subscribe to GCM/FCM and receive notifications within a node process.
A library to subscribe to GCM/FCM and receive notifications within a node process.
For electron, you can use electron-push-receiver instead which provides a convenient wrapper.
push-receiver
?push-receiver
?npm i -S push-receiver
You can use electron-push-receiver instead which provides a convenient wrapper.
const { register, listen } = require('push-receiver');
// First time
// Register to GCM and FCM
const credentials = await register(senderId); // You should call register only once and the store the credentials somewhere
storeCredentials(credentials) // Store credentials to use it later
const fcmToken = credentials.fcm.token; // Token to use to send notifications
sendTokenToBackendOrWhatever(fcmToken);
// Next times
const credentials = getSavedCredentials() // get your saved credentials from somewhere (file, db, etc...)
// persistentId is the id of the last notification received to avoid receiving all already received notifications on start.
const persistentId = getPersistentId() // get your last persistentId from somewhere (file, db, etc...), can be null
await listen({ ...credentials, persistentId}, onNotification);
// Called on new notification
function onNotification({ notification, persistentId : newPersistentId }) {
savePersistentId(newPersistentId);
// Do someting with the notification
display(notification)
}
To test, you can use the send script provided in this repo, you need to pass your serverKey and the FCM token as arguments :
node scripts/send --serverKey="<FIREBASE_SERVER_KEY>" --token="<FIREBASE_TOKEN>"
FAQs
A module to subscribe to GCM/FCM and receive notifications within a node process.
The npm package push-receiver receives a total of 1,699 weekly downloads. As such, push-receiver popularity was classified as popular.
We found that push-receiver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.