Firebase Cloud Messaging-具有多个主题-无消息重复 [英] Firebase Cloud Messaging - having multiple topics - without message duplication

查看:86
本文介绍了Firebase Cloud Messaging-具有多个主题-无消息重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读Firebase Cloud Messaging(FCM)的文档,我想知道是否有人遇到过同样的问题.

I've been going through documentation for Firebase Cloud Messaging (FCM), and I was wondering if anyone has this same issue.

我有一个供稿,用户有时可以在其中订阅多个重叠的主题.例如#News,#Weather可能在有关天气事件的帖子中.

I have a feed, where users can sometimes have multiple overlapping topics that the can be subscribed to. e.g. #News,#Weather could be in a post about a weather event.

给出的示例检查新闻"或天气" (主题中的新闻" ||主题中的天气")

The example given checks for either News or Weather ('News' in topics || 'Weather' in topics) in topics

我的问题是,FCM是否会选择遇到的第一个选项.具有"news"标签的新闻和消息人,或者它还会发送两次相同的消息-创建重复消息吗? (向用户发送1条新闻,向天气发送1条新闻.

My question is, will FCM just pick the first option it comes across eg. News and message people with the "news" tag, or will it also send the same message twice - creating a duplicate? (1 for news to a user, then 1 for weather).

提前谢谢! 基兰(Kieran)

Thanks in advance! Kieran

推荐答案

一个简单的测试应该可以弄清楚这一点.相应的用户只会收到一个消息. FCM服务器根据条件处理请求,在这种情况下,您使用的是OR条件-意思是,一旦其中一个条件变为真(在您的方案中,第一个条件是令牌是否已订阅)到News),则服务器将照常发送通知,而忽略其他条件.

A simple test should be able to figure this out. The corresponding users would only receive one message. The FCM server processes the request depending on the condition, in this case, you were using an OR condition -- meaning, as soon as one of the conditions becomes true (in your scenario, the first condition is if the token is subscribed to News), then the server would send the notification as per usual and would ignore the other conditions.

PS:我在发布之前已经对此进行了测试,因此我对这种行为持肯定态度.

PS: I tested this out before posting, so I'm positive of the behavior.

这篇关于Firebase Cloud Messaging-具有多个主题-无消息重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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