我正在使用Amazon SNS Mobile Push Notifications for android和ios . 我发送带有文本和图标的推送通知非常成功 . 现在我正在尝试发送带有图像底部的通知 . 我搜遍了每一个地方,但找不到一个完美的文档来工作 . 请给我任何建议 .
我用npm安装了这个软件包,用它来发送推送通知 . 请参考此链接 . 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)向用户发送消息 . message参数可以是String,也可以是具有以下格式的Object . 回调格式是回调(错误,messageId) .
从文档中它表示发送endpointArn,消息,我们将获得任何响应的回调 . 我想将图像与图像一起发送是可能的或任何其他方式来做到这一点 .
谢谢 .
1 回答
发送的每个包含图像的推送通知都可以包含mediaReference,该应用可以在以后用于从Web服务或应用程序捆绑资源中获取内容 .
在任何媒体案例中,最终资源链接/ bundle-resource-ref . 可以在app中组合,(示例)取决于推送中的其他参数 .
请记住,如果资源未捆绑,则必须在显示通知之前下载图像(使用它)
所以解决方案是在客户端...为你的每个平台(android和ios)实现特定的方法,执行所需的操作(我重复,不同和特定于平台),以显示推送通知与图片 .
NOTE : 如果您需要使用图片构建平台特定通知的参考,请告诉我 . (如果是的话,你为每个使用什么min sdk版本)