3 6

Send a push notification in node with OneSignal

Send a push notification in node with OneSignal : 
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
var request = require('request'); var sendMessage = function(user, message){ var restKey = '****'; var appID = '****'; request( { method:'POST', uri:'', headers: { "authorization": "Basic "+restKey, "content-type": "application/json" }, json: true, body:{ 'app_id': appID, 'contents': {en: message}, 'include_player_ids': [user] } }, function(error, response, body) { if(!body.errors){ console.log(body); }else{ console.error('Error:', body.errors); } } ); } sendMessage('a9fb63b1-b5cc-4ee9-92f0-5be15eb300c0', 'Hello!');
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus