【问题标题】:How can I disable headsup notification from FCM and only work with onMessage and onBackgroundMessageHanlder如何禁用来自 FCM 的抬头通知并仅使用 onMessage 和 onBackgroundMessage 处理程序
【发布时间】:2021-09-15 19:05:37
【问题描述】:

如何禁用来自 FCM 的提示通知并仅使用

  onMessage()

和

  onBackgroundMessageHanlder()

【问题讨论】:

    标签: android ios flutter dart firebase-cloud-messaging


    【解决方案1】:

    显示自动通知是因为您正在发送通知消息。对于通知消息,FCM 会代表客户端应用自动将消息显示给最终用户设备。

    解决方案:

    您可以发送不显示自动通知并需要客户端应用程序处理数据的数据消息。

    这是一个示例通知消息:

    {
      "message":{
        "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
        "notification":{
          "title":"Portugal vs. Denmark",
          "body":"great match!"
        }
      }
    }
    

    这是一个示例数据消息:

    {
      "message":{
        "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
        "data":{
          "Nick" : "Mario",
          "body" : "great match!",
          "Room" : "PortugalVSDenmark"
        }
      }
    }
    

    更多阅读:https://firebase.flutter.dev/docs/messaging/usage 和 https://firebase.google.com/docs/cloud-messaging/concept-options

    【讨论】:

    • 谢谢维克多的回答,我明白了
    猜你喜欢
    • 2018-04-07
    • 1970-01-01
    • 2017-07-17
    • 2021-01-21
    • 2021-08-03
    • 1970-01-01
    • 1970-01-01
    • 2020-09-01
    • 2018-07-31
    相关资源
    最近更新 更多