有没有办法回滚向 GCM 服务器发出的通知请求?
例如,考虑将 GCM 消息请求放置到 GCM 服务器。 如果用户在手机上线之前在网络上看到消息,则应回滚 GCM 请求。用户不应在移动设备中看到通知。
最佳答案
在您描述的情况下,没有用于此类回滚的内置机制。您可以尝试自己实现它 - 当您的服务器注意到该消息已在 Web 中查看时,您可以向设备发送另一条 GCM 消息,其中包含一些表示需要回滚的数据。当您处理该消息时,您应该清除您的应用在该设备上创建的所有通知(我不确定这是否可行,您必须检查一下)。
在类似情况下有这样一种机制 - 如果用户有多个 Android 设备,并且您向所有这些设备发送 GCM 消息(使用新的 user notifications 功能),一旦用户在一个设备上查看通知,它将自动从其他设备中删除。
- 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.
关于android - 回滚/取消 android-gcm 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17865384/