rollback/cancel the android-gcm notification

我的未来我决定 提交于 2019-12-19 17:27:11

问题


Is there a way to rollback the notification request placed to GCM server?

As in, consider a GCM-message-request is placed to GCM server. If the user sees the message in web before coming online in mobile, the GCM request should be rolled back. And user should not see the notification in mobile.


回答1:


There is no built in mechanism for such rollback in the case you describe. You can try implementing it yourself - when your server notices the message was viewed in web, you can send another GCM message to the device with some data that represents a need to rollback. When you process that message, you should clear any notifications that were created by your app on that device (I'm not sure if that's possible, you'll have to check).

There is such a mechanism in a similar case - if the user has multiple Android devices, and you send a GCM message to all of them (using the new user notifications feature), once the user views the notification on one device, it would be automatically removed from the other devices.

  • If a message has been handled on one device, the GCM message on the other devices are dismissed. For example, if a user has handled a calendar notification on one device, the notification will go away on the user's other devices.
  • If a message has not been delivered yet to a device and but it has been handled, the GCM server removes it from the unsent queue for the other devices.


来源:https://stackoverflow.com/questions/17865384/rollback-cancel-the-android-gcm-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!