使用uid作为Firebase Messaging主题? [英] Using uid as Firebase Messaging topics?

查看:76
本文介绍了使用uid作为Firebase Messaging主题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近问了一个 SO问题,询问如何使用Firebase Messaging主题将消息发送给组中除触发通知的人员(向数据库中的组部分进行写操作)之外的所有人.我得到了一个有趣的答案,涉及为我的iOS应用程序的每个用户创建一个主题,然后仅使用为每个成员创建的主题向组中的每个成员发送一条消息.主题的名称将只是该人的uid,因此我只遍历该组成员的uid,并向其对应的主题发送一条消息(忽略触发用户的uid).

I recently asked a SO question asking how to send a message using topics for Firebase Messaging to everybody in a group except the person who triggered the notification (A write to the group's section in the database). I got an interesting answer that involves making a topic for every user of my iOS application, then just sending out a message to every member of a group using the topic made for each member. The topic's name would just be the person's uid, so I just iterate through the group's members' uids and send a message to their corresponding topic (ignoring the triggering user's uid).

使用此解决方案将意味着我的应用程序的每个用户都有自己的主题(/topics/<uid1>/topics/<uid2>等).我想知道这样做是否有任何弊端.这将简化我的云功能以发送消息,但是我不确定是否有那么多主题在成本和性能方面是否昂贵.谁能帮我找出这是否是一个好的解决方案?

Using this solution would mean every user of my application has their own topic (/topics/<uid1>, /topics/<uid2>, etc.). I was wondering if doing something like this has any drawbacks. It would simplify my cloud function for sending out messages but I'm unsure of whether having so many topics is expensive in terms of cost and performance. Can anybody help me figure out if this is a good solution?

推荐答案

我在此博客文章中使用了类似的方法:

I use a similar approach in this blog post: Sending notifications between Android devices with Firebase Database and Cloud Messaging. The only difference is that we use a username there, to make the use-case easier to read.

这种方法的一些问题:

  • 主题是公开的,任何人都可以订阅主题.就您而言,UID可能比博客文章中的用户名更容易猜测,但仍然不安全.
  • FCM针对具有大量令牌的合理数量的主题进行了优化.因此,从技术上讲,它将与更多较小的主题配合使用,但并非为此目的而设计的. YMMV

这篇关于使用uid作为Firebase Messaging主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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