使用Flutter应用程序从Firebase云消息传递发送推送通知

huangapple go评论68阅读模式
英文:

Send push notification with Firebase cloud messaging from Flutter app

问题

有没有办法从Flutter应用程序自动发送通知,或者当实时数据库更新时发送通知?

我有一个包含产品和商店的应用程序,我想在商店添加新产品时发送推送通知,以通知所有顾客商店已添加新产品。

是否有办法在没有后端服务器的情况下执行类似这样的操作?

英文:

Is there any way to send Notification automatically from flutter app or when Realtime database updates?

i have app that contains products, stores and i want to send push notification when store add new product to notify all customers that the store added new products

is there any way to do something like this without backend server?

答案1

得分: 2

不,没有后端是不行的。但你可以使用“无服务器”解决方案,比如云函数来完成这个任务。

英文:

No, not without any form of backend. You could use "serverless" solutions such as cloud functions to do the task though.

答案2

得分: 1

Is there any way to send Notification automatically when Realtime database updates without backend server?

你可以使用Cloud Functions,这是Google/Firebase的“无服务器框架,允许您根据Firebase功能触发的事件自动运行后端代码”。

Cloud Functions示例库中有一个示例,演示了如何从Realtime Database触发的函数中发送Firebase Cloud Messaging (FCM)通知。

FCM文档还显示了多个代码示例(如果您使用Cloud Function第1代,请查看Node.js选项卡,如果您使用Cloud Function第2代,请查看Node.js或Python选项卡)。

英文:

> Is there any way to send Notification automatically [...] when
> Realtime database updates [...] without backend server?

You can use Cloud Functions, the Google/Firebase "serverless framework that lets you automatically run backend code in response to events triggered by Firebase features".

There is an example in the Cloud Functions samples library which demonstrates how to send a Firebase Cloud Messaging (FCM) notification from a Realtime Database triggered Function.

The FCM documentation also shows several code examples (see the Node.js tabs if you use Cloud Function 1st generation, or Node.js or Python tab if you use Cloud Function 2nd generation).

huangapple
  • 本文由 发表于 2023年6月8日 15:25:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76429518.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定