【问题标题】:Send Push Notification when user submit Contact form flutter [closed]用户提交联系表单时发送推送通知颤动[关闭]
【发布时间】:2022-10-16 19:46:13
【问题描述】:

我正在开发一个 Flutter 项目,我正在寻找 Flutter 推送通知。我该怎么做才能在用户提交表单时发送通知,然后在我们向他们发送电子邮件时收到通知?

【问题讨论】:

    标签: flutter forms notifications push


    【解决方案1】:

    是的,首先您需要存储用于每个帐户的设备令牌。您可以将其存储在 Firebase 中。 这是用于查看设备令牌的代码:

    @override
      void initState()  {
        FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; // Change here
        _firebaseMessaging.getToken().then((token){
          print("token is $token");
      });
    }
    

    只需将该设备令牌添加到 Firebase 特定用户

    此代码用于发送特定通知

    const admin = require("firebase-admin");
    
    await admin.messaging().sendMulticast({
      tokens: ["token_1", "token_2"],
      notification: {
        title: "Weather Warning!",
        body: "A new weather warning has been issued for your location.",
        imageUrl: "https://my-cdn.com/extreme-weather.png",
      },
    });
    

    在令牌中,您需要放置要向其发送通知的用户令牌。

    欲了解更多信息,您可以查看此页面:https://firebase.flutter.dev/docs/messaging/notifications/

    我还建议您观看一些带有一些示例的 youtube 视频

    【讨论】:

    • 感谢您提供信息,当用户提交表单时,此方法是否也提供自动回复通知?
    • 我们在谈论什么形式?它是内置在应用程序中的吗?
    • 是:喜欢联系表格
    • 好吧,您可以在使用他自己的设备令牌的发送表单中的 onPressed(){} 中按下按钮后立即放入该行代码。
    • 谢谢,我会尽快更新我的问题
    猜你喜欢
    • 2022-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多