The official Node.js package for sending push notifications with Pushy.
Pushy is the most reliable push notification gateway, perfect for real-time, mission-critical applications.
Note: If you don't have an existing Node.js project, consider using our sample Node.js API project as a starting point to make things easier for you.
First, install the package using npm:
npm install pushy --save
Then, use the following sample code to send a push notification to target devices:
var Pushy = ;// Plug in your Secret API Key// Get it here:var pushyAPI = 'SECRET_API_KEY';// Set push payload data to deliver to device(s)var data =message: 'Hello World!';// Insert target device token(s) herevar tokens = 'DEVICE_TOKEN';// Set optional push notification options (such as TTL)var options =// Set the notification to expire if not delivered within 30 secondstime_to_live: 30;// Send push notification via the Push Notifications API//pushyAPI;
Alternatively, send the notification using promises:
Make sure to replace
SECRET_API_KEY with your app's Secret API Key listed in the Dashboard.