有没有办法用 firebase 自动发送 notificatins 到 flutter 应用程序

is there a way to send notificatins automatically with firebase to flutter application

我正在开发一个 flutter 应用程序,如果有人关注我,我想向用户发送通知 user.I 我正在使用 firebase 和 FCM 发送通知,但我只能通过 hand.is 发送它们当有人关注用户等时自动向用户发送通知的方法?

是的,您需要使用 Firebase 云消息传递的服务器端,如 doc:

中所述

The server side of Firebase Cloud Messaging consists of two components:

  • The FCM backend provided by Google.
  • Your app server or other trusted server environment where your server logic runs, such as Cloud Functions for Firebase or other cloud environments managed by Google.

Your app server or trusted server environment sends message requests to the FCM backend, which then routes messages to client apps running on users' devices.

最简单的解决方案很可能是使用 Cloud Functions,除非您手边有自己的服务器。

官方示例列表中有一个 Cloud Functions 示例:https://github.com/firebase/functions-samples/tree/master/fcm-notifications. The message sending is triggered by a new "record" in the Realtime Database but it is quite easy to adapt it to be triggered by Firestore documents 创建。