Android FCM通知分组 [英] Android FCM notification grouping

本文介绍了Android FCM通知分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为一个聊天应用程序实现FCM通知,并且我想实现类似WhatsApp的通知,通知将按照对话分组。



说当爱丽丝回答与鲍勃的谈话时,鲍勃将收到身体爱丽丝:内容的通知。但是,如果爱丽丝很快回复了对话,鲍勃会得到另一个新的通知,但我只是想将新的回复追加到prev通知上。

我怎么能做到这一点?

解决方案

通知有效载荷中的'tag':

lockquote

tag可选,字符串

用于替换通知中现有通知的标识符抽屉。
如果未指定,每个请求会创建一个新的通知。
如果已指定,并且具有相同标记的通知已被显示,则新通知会替换通知抽屉中的现有通知。


来源: https:// firebase .google.com / docs / cloud-messaging / xmpp-server-ref#notification-payload-support

I was trying to implement FCM notification for a chat app and I want to achieve "WhatsApp-like" notification where the notification will be grouped by conversation.

Say when Alice replied to a conversation with Bob inside, Bob will receive a notification with the body "Alice: the content". But if Alice quickly reply to the conversation again, Bob will get another new notification but I just want to append the new reply onto the prev notification instead.

How can I achieve that?

解决方案

You can use the 'tag' in the notification payload:

tag Optional, string
Identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification. If specified and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer.

source: https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref#notification-payload-support

这篇关于Android FCM通知分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆