禁用 firebase 自动显示通知

问题描述 投票:0回答:2

我只想通过 OnMessageReceived 方法接收通知数据,然后使用 Unity 的 MobileNotification 或 UTNotification 显示自定义通知。

firebase unity-game-engine push-notification firebase-cloud-messaging
2个回答
2
投票

当应用程序未激活时,消息的

notification
属性中的任何信息都会由系统自动处理。如果您不希望系统自动显示通知,请确保您的消息不包含
notification
属性。系统不会自动显示纯数据消息。

有关此内容的更多信息,另请参阅有关 消息类型的 Firebase 文档。


虽然可以在其他选项

自定义数据
部分将data属性添加到通过Firebase控制台发送的FCM消息中,但无法发送仅数据消息。通过 Firebase 控制台发送的消息始终具有 notification 属性,这会触发系统显示它们。
如果您想发送纯数据消息,最简单的方法是通过 CURL 命令,如下所示:

如何在不使用 Firebase 控制台的情况下发送 Firebase 云消息通知?


0
投票
https://firebase.google.com/docs/cloud-messaging/concept-options?hl=fr#notifications_and_data_messages

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

不要将关键通知放在您的正文请求中 { "message":{ "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "notification":{ "title":"Portugal vs. Denmark", "body":"great match!" }, "data" : { "Nick" : "Mario", "Room" : "PortugalVSDenmark" } } }

© www.soinside.com 2019 - 2024. All rights reserved.