I wanted to ask how can i send AWS SNS push notification end to end means i don't want to use the console for creating endpoints and arn I want to send the notification using nodejs. I am able to send the notification for one device using console and taking that endpoint to publish the notification. I wanted to ask how can i implement fully using nodejs. here is my tried solution
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: "",
secretAccessKey:"",
region: "us-east-1"
});
var sns = new AWS.SNS();
let payload2 = JSON.stringify({
default: 'Practice',
GCM: JSON.stringify({
notification : {
body : 'great match!',
title : 'Portugal vs. Denmark'
},
data:{
testdata: 'Check out these awesome deals!',
url: 'www.amazon.com'
}
})
});
console.log(payload2)
console.log('sending push');
sns.publish({
Message: payload2, // Required
MessageStructure: 'json',
TargetArn: 'Arn from console' // Required
}, function(err, data) {
if (err) {
console.log(err.stack);
return;
}
console.log('push sent');
console.log(data);
});
I also wants to know how can i send the batch push notification to the multiple devices?