按主题使用 FCM 的 Flutter 推送通知

Flutter push notification using FCM by topic

你好我是 flutter 的新手并试图在 flutter 中获取推送通知,我已经成功地为用户订阅了一个主题并通过 firebase 控制台按主题发送了一个通知,我想要做的是在应用程序中有一个供管理员使用的按钮,当他们 post 针对特定主题时,具有该主题的用户会收到通知 我听说过云功能,但我不知道从哪里开始!我希望我表达了我的观点!我看过一些讨论类型脚本的视频,但是有什么解决方法吗?

Firebase 文档将 notifying the user when something interesting happens 命名为示例 ​​use-case。从那里:

Developers can use Cloud Functions to keep users engaged and up to date with relevant information about an app. Consider, for example, an app that allows users to follow one another's activities in the app. Each time a user adds themselves as a follower of another user, a write occurs in the Realtime Database. Then this write event could trigger a function to create Firebase Cloud Messaging (FCM) notifications to let the appropriate users know that they have gained new followers.

  1. The function triggers on writes to the Realtime Database path where followers are stored.
  2. The function composes a message to send via FCM.
  3. FCM sends the notification message to the user's device.

To review working code, see Send FCM notifications.