Skip to content

Instantly share code, notes, and snippets.

@sirgalleto
Created June 17, 2016 05:18
Show Gist options
  • Save sirgalleto/81b76d2403efd8ec51586198631a77cd to your computer and use it in GitHub Desktop.
Save sirgalleto/81b76d2403efd8ec51586198631a77cd to your computer and use it in GitHub Desktop.
Send push not with onesignal
'use strict';
var rp = require('request-promise');
module.exports = function(data, userId){
return rp({
method: 'POST',
uri: 'https://onesignal.com/api/v1/notifications',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + process.env.ONESIGNAL_API_KEY
},
body: {
'app_id': process.env.ONESIGNAL_APP_ID,
'contents': {
en: `${data.message}: ${data.description}`
},
'tags': [{'key': 'userId', 'relation': '=', value: userId}]
},
json: true
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment