simple-onesignal
A simple Node.js wrapper for onesignal. Used to send Push Notifications to end-users.
Sign up for free at: onesignal.com
Install
npm install simple-onesignal
Setup
var onesignal = ;onesignal;
Usage
Sending a message
The sendMessage
method accepts either a string, or an Object. If you decide to send an object, ensure it is in the correct format as described below.
Simple Text to everyone
The following code will send a message in English to all subscribers!
onesignal;
Message with specific messages and targeting
onesignal;
Convenience methods
The following methods essentially do the same as sendMessage([data])
, but wrap some of the boiler plate up for you.
Send text to segments
The second argument is an array of your segments configured in OneSignal.
onesignal;
Send text to filters
The second argument is an array of your filters configured in OneSignal. In the example below, we are targeting users who have not opened the app for at least 12 hours.
var filters = field:'last_session' relation:'>' hours_ago:'12' onesignal;
License
© Jamie Chapman, 57Digital Ltd — ISC