使用 Node.js 的带图像的 SNS 推送通知?
SNS Push Notifications with image using Node.js?
我正在为 android 和 ios 使用 Amazon SNS 移动推送通知。我非常成功地发送仅包含文本和图标的推送通知。现在我正在尝试发送带有图像底部的通知。我搜索了所有地方,但找不到可以处理的完美文档。有什么建议吗
我使用 npm 安装了这个包,我用它来发送推送通知。请参考这个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 a user.
The message parameter can be a String, or an Object with the formats
below. The callback format is callback(err, messageId).
从文档中它指示发送一个 endpointArn 消息,我们将得到任何响应的回调。我想连同图像一起发送图像,是可能的还是任何其他方式来做到这一点。
谢谢。
发送的每个包含图像的推送通知都可以包含一个 mediaReference,应用稍后可以使用它从网络服务或应用捆绑资源中获取内容。
在任何媒体情况下,最终资源 link / bundle-resource-ref。可以在应用程序中组合,(示例)取决于推送中的其他参数。
请记住,如果资源未捆绑,您必须在显示通知(使用它)之前下载图像
所以解决方案是在客户端...
为您的每个平台实施特定方法(android & ios),执行所需的操作(我重复,不同且特定于平台)以显示带有图像的推送通知。
注意:
如果您需要参考来构建带有图像的平台特定通知,请告诉我。 (如果是这样,您为每个使用的最低 sdk 版本)
我正在为 android 和 ios 使用 Amazon SNS 移动推送通知。我非常成功地发送仅包含文本和图标的推送通知。现在我正在尝试发送带有图像底部的通知。我搜索了所有地方,但找不到可以处理的完美文档。有什么建议吗
我使用 npm 安装了这个包,我用它来发送推送通知。请参考这个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 a user. The message parameter can be a String, or an Object with the formats below. The callback format is callback(err, messageId).
从文档中它指示发送一个 endpointArn 消息,我们将得到任何响应的回调。我想连同图像一起发送图像,是可能的还是任何其他方式来做到这一点。
谢谢。
发送的每个包含图像的推送通知都可以包含一个 mediaReference,应用稍后可以使用它从网络服务或应用捆绑资源中获取内容。
在任何媒体情况下,最终资源 link / bundle-resource-ref。可以在应用程序中组合,(示例)取决于推送中的其他参数。
请记住,如果资源未捆绑,您必须在显示通知(使用它)之前下载图像
所以解决方案是在客户端... 为您的每个平台实施特定方法(android & ios),执行所需的操作(我重复,不同且特定于平台)以显示带有图像的推送通知。
注意: 如果您需要参考来构建带有图像的平台特定通知,请告诉我。 (如果是这样,您为每个使用的最低 sdk 版本)