我正在尝试为聊天应用实现 FCM 通知,我想实现类似 WhatsApp"的通知,其中通知将按对话分组.
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.
假设当 Alice 回复与 Bob 在里面的对话时,Bob 将收到一条正文为Alice:内容"的通知.但是,如果 Alice 再次快速回复对话,Bob 将收到另一个新通知,但我只想将新回复附加到 prev 通知上.
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?
通过 grouping 通知,我假设您的意思是 stacking 或 捆绑通知.
By grouping the notification, I'm presuming you mean stacking or bundling notifications.
更多关于如何在客户端应用中处理通知.您只需使用 setGroup() 将所有通知添加到一个组,然后调用 notify() 让 NotificationManager 进行更改.
This is more on how you handle the notification in your client app. You simply have to make use of the setGroup() to add all your notifications to a single group then calling notify() to let the NotificationManager of the changes.
这个将每个通知添加到一个组文档差不多总结了这一切.
This Add Each Notification to a Group documentation pretty much sums it all up.
这篇关于Android FCM 通知分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!