android - 回滚/取消 android-gcm 通知

标签 android push-notification google-cloud-messaging

有没有办法回滚向 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/

相关文章:

ios - 推送通知更改 AppIcon 的角标(Badge)

仅选择一列时Android房间类型转换器不转换

android - 混帐 : How to Push missing branches from one repo to another repo

java - Android:从使用 MessagingStyle 的通知中获取消息

ios - 需要有关在 iOS 中请求通知权限的说明

java - 从 Google Cloud Messaging 收到未经授权的 401 错误,并且我正在使用允许所有 IP 的服务器 API key

android - GCM 在 onTokenRefresh() 之后重新订阅主题

google-cloud-messaging - Google PubSub 错误 [代码=8a75]

java - Android - 按钮不会切换 fragment

Android SeekBar 标记值在哪里