我正在使用node-gcm向 android 设备发送通知,在某些情况下,我需要发送带有通知的图像以显示为缩略图,如下所示: notification with thumbnail
有时我需要发送没有缩略图的通知。使用下面的代码,我可以在通知中发送图像,问题是当收到另一个通知时,它们会崩溃,使新通知覆盖已经存在的通知:
var message = new gcm.Message({
"data" : {
"title" : "Test",
"message" : "Test message!",
"priority" : 2, // Highest priority.
"ledColor" : [255, 0, 0, 1],
"content-available": "1",
"image": req.body.notificationImageUrl, //<-- image URL
},
});
但是,如果我像下面这样设置消息,我找不到发送图像的方法,但通知不会折叠并且所有通知都会出现。另一个问题是这个版本的led没有激活:
var message = new gcm.Message({
data: {
"priority" : 2, // Highest priority.
"content-available": "1",
"image": req.body.notificationImageUrl, // <-- image URL
},
notification:{
title: "Test",
body: "Test message!",
color: "#892121",
sound: 'default',
vibrationPattern: [300, 150, 300], // Vibrate for 300ms then wait 150ms and then vibrate for 300ms.
ledColor: [255, 0, 0, 1], // <-- this does not work
},
});
我想要的是一种发送带有缩略图的通知的方法,它不会覆盖以前存在的通知。
编辑:我忘了提一下,我将 Ionic Framework 与 Cordova 一起使用,所以我无法管理设备中的通知,除非有办法通过这些框架来做到这一点。提前致谢!