简体   繁体   English

Android Firebase通知-通知用户评论回复

[英]Android Firebase Notifications - Notify users to comment reply

Im trying to create a feature on an app where users can be notified that someone replied to something they posted. 我试图在应用程序上创建功能,以便可以通知用户有人回复了他们发布的内容。

So far i have setup Firebase Notifications so i can send notifications from the firebase dashboard to an individual device, a group subscribed to a topic etc.. 到目前为止,我已经设置了Firebase通知,因此我可以将通知从Firebase仪表板发送到单个设备,订阅主题的组等。

How do i add a feature that when a registered user posts something that fits a criteria it will post it to the group and the subscribed users will be notified. 我如何添加功能,当注册用户发布符合条件的内容时,它将发布到组中并通知订阅的用户。

I assume it just need to be able to allow users to post to certain "topics" and firebase will send the notifications but how do i allow a user to post directly to a topic from the app? 我认为它只需要能够允许用户发布到某些“主题”,并且Firebase会发送通知,但是我如何允许用户从应用程序直接发布到主题?

Thanks 谢谢

You can setup a Firebase cloud function on the Realtime Database location using wildcards and this function can then call the Firebase cloud messaging REST api with Topic/Regid that you want. 您可以使用通配符在Realtime Database位置上设置Firebase云功能,然后该功能可以使用所需的Topic / Regid调用Firebase云消息传递REST api。

Check out more about Firebase Cloud functions: 进一步了解Firebase Cloud功能:

https://firebase.google.com/products/functions/ https://firebase.google.com/products/functions/

Alternatively, you can do this from the client side as well.... Basically if someone posts something under a Location in RDB, Call the Firebase Cloud Messaging Rest api for the creator of the node. 或者,您也可以从客户端进行此操作。...基本上,如果有人在RDB中某个位置下发布内容,请为该节点的创建者调用Firebase Cloud Messaging Rest api。 I would suggest subscribing each user to a Topic which is their own userid. 我建议为每个用户预订一个Topic,这是他们自己的用户ID。 This way, when anyone posts, you can send a FCM push to this userid topic. 这样,当任何人发帖时,您都可以将FCM推送发送到该userid主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM