I have a node.js project that I use for the backend application, I need to send push notifications to Android and ios, the fact is that APNS sometimes gives me a 500 error trying to send a notification.
Here's the usual answer:
{ sent: [],
failed: [ { device: '<device_id>',
status: '500',
response: { reason: 'InternalServerError' } } ]
I read that if you send a lot at a time, APNS may refuse to connect, the fact is that I usually do not send as many as a maximum of 1 notification per second.
I use node-apn, heres code that sends a notification.
function sendIosNotification(deviceTokens,body,data,musico) {
var notification = new apn.Notification();
if (musico) {
notification.topic = "<name_goes_here>.musico";
} else {
notification.topic = "<name_goes_here>.cliente";
}
notification.alert = body;
notification.badge = 1;
notification.sound = "dong.aiff";
notification.payload = data;
apnProvider.send(notification, deviceTokens)
.then( (response) => {
console.log(response);
console.log(response.failed);
});
}
, , , , , 500. node, . -, , ?, APNS -, ?
EDIT: npm https://www.npmjs.com/package/apn