SNS push notifications with image using Node.js?

I am using Amazon SNS Mobile Push Notifications for Android and ios. I pretty successfully sent a push notification with just the text and icon. Now I'm trying to send a notification from the bottom of the image. I searched everything, but could not find the ideal documents for the job. Any suggestions please.

I installed this package using npm, I used this to send push notifications. please refer to this link. https://www.npmjs.com/package/sns-mobile

AWS_SNS_App.getUsers(function (err, allDevices) { if (err) { console.log(err, err.stack); // an error occurred } else { if (allDevices.length != 0) { var totalDevices = 0; for (var i = 0; i < allDevices.length; i++) { totalDevices = totalDevices + 1; AWS_SNS_App.sendMessage(allDevices[i].EndpointArn, message, function (err, messageId) { if (err) { console.log('An error occured sending message to device %s'); res.send(err); } else { //res.send('Successfully sent a message to device , MessageID was : ' + messageId); } }); } if (totalDevices === allDevices.length) { res.send('Successfully sent a message to all devices'); } } } }); 

sendMessage (endpointArn, message, callback) Send a message to the user. The message parameter can be a string or an object with the formats below. The callback format is a callback (err, messageId).

from the documents indicates the endpointArn message is sent, and we will receive a callback to any response. that I can send the image along with the image is possible or in any other way to do this.

thanks.

+8
amazon-web-services amazon-sns push-notification
source share
1 answer

Each sent notification containing an image may contain mediaReference, which the application can subsequently use to receive content from a web service or from resources associated with applications.

In any case, the media is the final link of the resource / package-resource-ref. can be compiled in an application (example) depending on other parameters inside push.

Remember that if the resource is not connected, you will need to upload the image before displaying the notification (using it)

So, the solution is on the client side ... Implement specific methods for each of your platforms (android and ios), perform the necessary operations (repeat, different and platform-specific) to display a push notification with an image.


NOTE: Tell me if you need links to create special notifications on the image platform. (and if so, which version of min sdk do you use for each)

+1
source share

All Articles