问题描述
我正在使用Firebase Notifications构建一个应用程序,用户可以在其中输入邮政编码,然后接收有关其本地发生的特定事件的通知.
I'm building an app using Firebase Notifications where a user can enter their zip code and then receive notifications for specific events happening in their locality.
如何仅将通知发送给特定用户?我曾尝试在Firebase Notifications的 Advanced Options 部分中包括邮政编码,但是它仍会将通知发送给所有用户.
How do I only send notifications to a specific user? I've tried including Zip Code in the Advanced Options sections of Firebase Notifications, but it still sends the notification to all users.
推荐答案
类似主题是您所需要的.当用户输入他们的邮政编码时,您可以为他们订阅一个主题,例如:/topics/zip,然后您可以从控制台发送到相应的邮政编码.订阅将创建该主题(如果该主题尚不存在).
Seems like Topics is what you are looking for. When the user enters their zipcode you can subscribe them to a topic eg: /topics/zip then you can send to the appropriate zipcode from the console. Subscribing will create the topic if it does not already exist.
注意:主题创建后最多可能需要24小时才能显示在控制台中.
Note: Topics can take up to 24 hours to show up in the console after they are created.
这篇关于Firebase通知-如何仅将通知发送给特定用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!