0

我目前正在使用 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
4

1 回答 1

0

我的建议是,尝试查看这个基础设施站点,它真的很棒并且摆脱了这些问题,而且它很容易实现。

以下是链接:

推送机器人链接

于 2017-01-24T13:56:21.323 回答