android - 您如何替换以前使用 Cloud Functions 发送的通知?你如何防止收到某些通知?

标签 android firebase google-cloud-functions

我使用 Firebase 存储通知所需的内容,并使用 Google Cloud Functions 发送通知。当用户决定使用应用程序时,他们会订阅该事件,以便他们可以接收聊天通知。

我的第一个问题是他们会收到每条消息的单独通知,我想这在群聊中会很烦人。我尝试使用 collapseKey,但我认为我要么用错了,要么误解了它的用途。是不是因为通知已经发送了,所以不工作?无论哪种方式,我该如何解决这个问题?

我的第二个问题是用户订阅了一个事件,但由于有时接收通知会有一点延迟,如果他们在发送通知之前退出应用程序,他们可以获得自己的消息通知。我该如何防止这种情况?

最佳答案

对于你的第一个问题, 使用

Pending intent flags

PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0 /* Request code */, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

有关标志的更多信息 Please visit this link

关于android - 您如何替换以前使用 Cloud Functions 发送的通知?你如何防止收到某些通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42916673/

相关文章:

android - 如何在 Eclipse 中使用低于 21 的 API 中的 Material 设计功能?

Javapoet 父类(super class)泛型

javascript - Promise.all 在 firebase 中使用 getDownloadURL()

firebase - 下载 Firebase 云函数

android - 在 Android 的 GridView 中滚动不起作用

javascript - 大型 Firebase 查询的进度事件?

swift - 如何在一笔事务中使用 Swift 删除 Firebase 中的多个路径

firebase - Google Cloud Platform 网络控制台 - 未显示云功能指标图

python - 使用 Functions Framework for Python 时如何在 Google Cloud Buildpacks 中设置运行时版本?

Android Google Play - 我应该许可我的付费应用程序还是可选的?