Recently discovered AWS and i'm doing great, today i want to send a test notification to my iPhone X. I'm trying to do so when my database get's an update, Using the dynamoDB trigger blueprint.
Regular Notifications Delivered on the Dashboard works
This is what i have tried to so far, I'm neither getting the rep console log on CloudWatch nor an error.
console.log('Loading function');
const async = require('async');
const https = require('https');
exports.handler = async (event, context) => {
console.log('Received event:', JSON.stringify(event, null, 2));
const name = "35b83a10-9f46-4c2c-95e1-22c6d40005a8";
var message = {
app_id: "appid",
contents: {"en": "Your order has arrived at your doorstep"},
include_player_ids: ["14894201-64f7-486a-b65e-6beedf5880f1",name,"8e0f21fa-9a5a-4ae7-a9a6-ca1f24294b86"]
};
sendNotification(message);
console.log("Activation change detected. message sent");
return `Successfully processed ${event.Records.length} records.`;
};
var sendNotification = function(data) {
var headers = {
"Content-Type": "application/json; charset=utf-8",
"Authorization": "Basic hidden_in_question"
};
var options = {
host: "onesignal.com",
port: 443,
path: "/api/v1/notifications",
method: "POST",
headers: headers
};
var req = https.request(options, function(res) {
res.on('data', function(data) {
console.log("rep:");
console.log(JSON.parse(data));
});
});
req.on('error', function(e) {
console.log("ERROR:");
console.log(e);
});
req.write(JSON.stringify(data));
req.end();
};
I do not get the message on my iPhone. What seems to be the problem here?
But getting:
Activation change detected. message sent
on the console.