我目前正在使用node-gcm向android设备发送推送通知。我目前的问题是,当我向一台设备发送多个推送通知时,最新的总是会通过旧的。因此,对于用户来说,他似乎只收到了一个推送通知。我想实现类似的方式来实现多个操作的推送通知,就像你在facebook / instagram中所做的那样。例如,在facebook中,你会收到每一个赞的推送通知,聊天消息等等。您可以在菜单中看到它们分开。
我使用node-gcm发送推送通知,并在应用程序端使用ionic-cordova / phopegap。
下面是我尝试发送它们的代码:
message = new gcm.Message
sender = new gcm.Sender '*************************************'
registrationIds = []
message.addData 'message', notification.message
message.addData 'title', notification.title
message.addData 'msgcnt','3'
message.addData 'NOTIFICATION_ID', Date.now()
message.addData 'ID', Date.now()
message.addData 'id', Date.now()
message.addData 'situation', notification.type
message.addData 'url', notification.url
PushId.find {userId: @_id}, (err, pushIds) ->
for singleId in pushIds
console.log 'Sending push to: ' + singleId.pushId
registrationIds.push singleId.pushId
sender.send message, registrationIds, 4, (result) ->
console.log 'Send done:' + result发布于 2017-01-24 21:56:21
https://stackoverflow.com/questions/41829608
复制相似问题